aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-04-02 15:24:37 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-04-02 15:24:37 +0800
commit9a38f851213392e4e4fefe017029306cba3d6ffe (patch)
tree31eefb7e313d5d9ca1ab5b53fbaef62765fe5e9f
parent9f642307d275beee2663cf2e2a0b41400aeec607 (diff)
downloadgsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar.gz
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar.bz2
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar.lz
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar.xz
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.tar.zst
gsoc2013-evolution-9a38f851213392e4e4fefe017029306cba3d6ffe.zip
mutex lock & unlock the context. (camel_pgp_clearsign): Same.
2001-04-02 Jeffrey Stedfast <fejj@ximian.com> * camel-pgp-context.c (camel_pgp_sign): mutex lock & unlock the context. (camel_pgp_clearsign): Same. (camel_pgp_verify): Same. (camel_pgp_encrypt): Same. (camel_pgp_decrypt): And finally here... svn path=/trunk/; revision=9096
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/camel-pgp-context.c49
2 files changed, 55 insertions, 0 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 63de9500f6..8c6b76e3ab 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
2001-04-02 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-pgp-context.c (camel_pgp_sign): mutex lock & unlock the context.
+ (camel_pgp_clearsign): Same.
+ (camel_pgp_verify): Same.
+ (camel_pgp_encrypt): Same.
+ (camel_pgp_decrypt): And finally here...
+
* camel-pgp-context.h: Update the function prototypes to match
those found in camel-pgp-context.c.
diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c
index 3193f5d8b2..05e5a190d5 100644
--- a/camel/camel-pgp-context.c
+++ b/camel/camel-pgp-context.c
@@ -49,12 +49,25 @@
#include <iconv.h>
+#ifdef ENABLE_THREADS
+#include <pthread.h>
+#define PGP_LOCK(ctx) g_mutex_lock (((CamelPgpContext *) ctx)->priv->lock)
+#define PGP_UNLOCK(ctx) g_mutex_unlock (((CamelPgpContext *) ctx)->priv->lock);
+#else
+#define PGP_LOCK(ctx)
+#define PGP_UNLOCK(ctx)
+#endif
+
#define d(x)
struct _CamelPgpContextPrivate {
CamelSession *session;
CamelPgpType type;
char *path;
+
+#ifdef ENABLE_THREADS
+ GMutex *lock;
+#endif
};
static CamelObjectClass *parent_class;
@@ -498,6 +511,8 @@ camel_pgp_sign (CamelPgpContext *context, const char *userid, CamelPgpHashType h
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
@@ -631,6 +646,8 @@ camel_pgp_sign (CamelPgpContext *context, const char *userid, CamelPgpHashType h
g_free (ciphertext);
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -639,6 +656,8 @@ camel_pgp_sign (CamelPgpContext *context, const char *userid, CamelPgpHashType h
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
@@ -650,6 +669,8 @@ camel_pgp_sign (CamelPgpContext *context, const char *userid, CamelPgpHashType h
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -682,6 +703,8 @@ camel_pgp_clearsign (CamelPgpContext *context, const char *userid, CamelPgpHashT
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
@@ -820,6 +843,8 @@ camel_pgp_clearsign (CamelPgpContext *context, const char *userid, CamelPgpHashT
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
@@ -831,6 +856,8 @@ camel_pgp_clearsign (CamelPgpContext *context, const char *userid, CamelPgpHashT
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -887,6 +914,8 @@ camel_pgp_verify (CamelPgpContext *context, CamelStream *istream,
char *sigfile = NULL;
int retval, i, clearlen;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
@@ -1023,12 +1052,16 @@ camel_pgp_verify (CamelPgpContext *context, CamelStream *istream,
g_free (diagnostics);
g_free (cleartext);
+ PGP_UNLOCK(context);
+
return valid;
exception:
g_byte_array_free (plaintext, TRUE);
+ PGP_UNLOCK(context);
+
return NULL;
}
@@ -1063,6 +1096,8 @@ camel_pgp_encrypt (CamelPgpContext *context, gboolean sign, const char *userid,
char passwd_fd[32];
char *passphrase = NULL;
+ PGP_LOCK(context);
+
/* get the plaintext in a form we can use */
plaintext = g_byte_array_new ();
stream = camel_stream_mem_new ();
@@ -1239,6 +1274,8 @@ camel_pgp_encrypt (CamelPgpContext *context, gboolean sign, const char *userid,
if (sign)
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -1247,6 +1284,8 @@ camel_pgp_encrypt (CamelPgpContext *context, gboolean sign, const char *userid,
camel_stream_write (ostream, ciphertext, strlen (ciphertext));
g_free (ciphertext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
@@ -1258,6 +1297,8 @@ camel_pgp_encrypt (CamelPgpContext *context, gboolean sign, const char *userid,
pgp_forget_passphrase (context->priv->session, context->priv->type, userid);
}
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -1289,6 +1330,8 @@ camel_pgp_decrypt (CamelPgpContext *context, CamelStream *istream,
char passwd_fd[32];
int retval, i;
+ PGP_LOCK(context);
+
/* get the ciphertext in a form we can use */
ciphertext = g_byte_array_new ();
stream = camel_stream_mem_new ();
@@ -1376,6 +1419,8 @@ camel_pgp_decrypt (CamelPgpContext *context, CamelStream *istream,
pgp_forget_passphrase (context->priv->session, context->priv->type, NULL);
+ PGP_UNLOCK(context);
+
return -1;
}
@@ -1384,6 +1429,8 @@ camel_pgp_decrypt (CamelPgpContext *context, CamelStream *istream,
camel_stream_write (ostream, plaintext, plainlen);
g_free (plaintext);
+ PGP_UNLOCK(context);
+
return 0;
exception:
@@ -1395,6 +1442,8 @@ camel_pgp_decrypt (CamelPgpContext *context, CamelStream *istream,
g_free (passphrase);
}
+ PGP_UNLOCK(context);
+
return -1;
}