aboutsummaryrefslogtreecommitdiffstats
path: root/mail/openpgp-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-02-23 05:40:26 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-02-23 05:40:26 +0800
commite939da9df48b7e4992de4df915e7832803f8fa12 (patch)
tree2baa5274b6b5601a6560bde5d15f0d7faf6d956b /mail/openpgp-utils.c
parent09515df40565b84e1fdcafce80015b51c0984567 (diff)
downloadgsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.gz
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.bz2
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.lz
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.xz
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.zst
gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.zip
Fixed memory corruption bug.
2001-02-22 Jeffrey Stedfast <fejj@ximian.com> * openpgp-utils.c (openpgp_verify): Fixed memory corruption bug. * mail-format.c (try_inline_pgp_sig): Check to make sure the validity isn't NULL. (handle_multipart_signed): Check for NULL validities. 2001-02-21 Jeffrey Stedfast <fejj@ximian.com> * mail-tools.c (mail_tool_uri_to_folder): Protect against NULL uri's. * mail-vtrash.c: Do mutex locking on the global hash table - this should clear up some segfaults ;-) * mail-config-druid.c (druid_finish): Set the 'enabled' member of the source to TRUE if the URL exists else set to FALSE. (incoming_type_changed): If the provider chosen is "None" then gray-out the auto-check widgets and the check-settings, otherwise sensitize them. * mail-account-editor.c (construct): Added a few more settings. (apply_changes): Save the new settings. * mail-config.c (service_copy): Updated. (config_read): Read in whether or not the account is enabled. (mail_config_write): Save if the account is enabled or not. svn path=/trunk/; revision=8349
Diffstat (limited to 'mail/openpgp-utils.c')
-rw-r--r--mail/openpgp-utils.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/mail/openpgp-utils.c b/mail/openpgp-utils.c
index 278dac0cdf..bb57036e60 100644
--- a/mail/openpgp-utils.c
+++ b/mail/openpgp-utils.c
@@ -1139,9 +1139,10 @@ openpgp_verify (const gchar *in, gint inlen, const gchar *sigin, gint siglen, Ca
if (diagnostics) {
char *charset;
- char *desc;
+ const char *buf;
+ char *desc, *outbuf;
iconv_t cd;
- size_t len, inlen;
+ size_t len, outlen;
charset = getenv ("CHARSET");
if (!charset)
@@ -1149,14 +1150,18 @@ openpgp_verify (const gchar *in, gint inlen, const gchar *sigin, gint siglen, Ca
cd = iconv_open ("UTF-8", charset);
- inlen = strlen (diagnostics);
- len = 2 * inlen;
- desc = g_malloc0 (len);
- if (iconv (cd, (const char **) &diagnostics, &inlen, &desc, &len) == -1) {
+ len = strlen (diagnostics);
+ outlen = 2 * len;
+
+ outbuf = desc = g_malloc0 (outlen + 1);
+ buf = diagnostics;
+ if (cd == (iconv_t) -1 || iconv (cd, &buf, &len, &outbuf, &outlen) == -1) {
g_free (desc);
desc = g_strdup (diagnostics);
}
- iconv_close (cd);
+
+ if (cd != (iconv_t) -1)
+ iconv_close (cd);
openpgp_validity_set_description (valid, desc);
g_free (desc);
@@ -1174,13 +1179,19 @@ openpgp_verify (const gchar *in, gint inlen, const gchar *sigin, gint siglen, Ca
PgpValidity *
openpgp_validity_new (void)
{
- return g_new0 (PgpValidity, 1);
+ PgpValidity *validity;
+
+ validity = g_new (PgpValidity, 1);
+ validity->valid = FALSE;
+ validity->description = NULL;
+
+ return validity;
}
void
openpgp_validity_init (PgpValidity *validity)
{
- g_return_if_fail (validity != NULL);
+ g_assert (validity != NULL);
validity->valid = FALSE;
validity->description = NULL;
@@ -1189,7 +1200,8 @@ openpgp_validity_init (PgpValidity *validity)
gboolean
openpgp_validity_get_valid (PgpValidity *validity)
{
- g_return_val_if_fail (validity != NULL, FALSE);
+ if (validity == NULL)
+ return FALSE;
return validity->valid;
}
@@ -1197,7 +1209,7 @@ openpgp_validity_get_valid (PgpValidity *validity)
void
openpgp_validity_set_valid (PgpValidity *validity, gboolean valid)
{
- g_return_if_fail (validity != NULL);
+ g_assert (validity != NULL);
validity->valid = valid;
}
@@ -1205,7 +1217,8 @@ openpgp_validity_set_valid (PgpValidity *validity, gboolean valid)
gchar *
openpgp_validity_get_description (PgpValidity *validity)
{
- g_return_val_if_fail (validity != NULL, NULL);
+ if (validity == NULL)
+ return NULL;
return validity->description;
}
@@ -1213,7 +1226,7 @@ openpgp_validity_get_description (PgpValidity *validity)
void
openpgp_validity_set_description (PgpValidity *validity, const gchar *description)
{
- g_return_if_fail (validity != NULL);
+ g_assert (validity != NULL);
g_free (validity->description);
validity->description = g_strdup (description);
@@ -1222,7 +1235,7 @@ openpgp_validity_set_description (PgpValidity *validity, const gchar *descriptio
void
openpgp_validity_clear (PgpValidity *validity)
{
- g_return_if_fail (validity != NULL);
+ g_assert (validity != NULL);
validity->valid = FALSE;
g_free (validity->description);
@@ -1232,7 +1245,8 @@ openpgp_validity_clear (PgpValidity *validity)
void
openpgp_validity_free (PgpValidity *validity)
{
- g_return_if_fail (validity != NULL);
+ if (validity == NULL)
+ return;
g_free (validity->description);
g_free (validity);