diff options
-rw-r--r-- | mail/ChangeLog | 4 | ||||
-rw-r--r-- | mail/mail-crypto.c | 31 |
2 files changed, 16 insertions, 19 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index c8052b75b0..a69dec671d 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,7 @@ +2001-01-23 Not Zed <NotZed@Ximian.com> + + * mail-crypto.c (pgp_mime_part_verify): Fix a double-free problem. + 2001-01-22 Jeffrey Stedfast <fejj@ximian.com> * mail-config-druid.c (incoming_type_changed): Oops, danw didn't diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index ae4ce6c803..b343e8cda8 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -257,12 +257,11 @@ pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) CamelDataWrapper *wrapper; CamelMultipart *multipart; CamelMimePart *part, *sigpart; - GByteArray *content, *sig; CamelStreamFilter *filtered_stream; CamelMimeFilter *crlf_filter; - CamelStream *stream; gboolean valid = FALSE; - + CamelStreamMem *sigstream, *cstream; + g_return_val_if_fail (mime_part != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), FALSE); @@ -274,31 +273,25 @@ pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) /* get the plain part */ part = camel_multipart_get_part (multipart, 0); - content = g_byte_array_new (); - stream = camel_stream_mem_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), content); - crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, - CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - filtered_stream = camel_stream_filter_new_with_stream (stream); + cstream = (CamelStreamMem *)camel_stream_mem_new (); + crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); + filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *)cstream); camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlf_filter)); camel_object_unref (CAMEL_OBJECT (crlf_filter)); camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (part), CAMEL_STREAM (filtered_stream)); camel_object_unref (CAMEL_OBJECT (filtered_stream)); - camel_object_unref (CAMEL_OBJECT (stream)); /* get the signed part */ sigpart = camel_multipart_get_part (multipart, 1); - sig = g_byte_array_new (); - stream = camel_stream_mem_new_with_byte_array (sig); - camel_data_wrapper_write_to_stream (camel_medium_get_content_object (CAMEL_MEDIUM (sigpart)), stream); - camel_object_unref (CAMEL_OBJECT (stream)); + sigstream = (CamelStreamMem *)camel_stream_mem_new (); + camel_data_wrapper_write_to_stream (camel_medium_get_content_object (CAMEL_MEDIUM (sigpart)), (CamelStream *)sigstream); /* verify */ - valid = openpgp_verify (content->data, content->len, - sig->data, sig->len, ex); - - g_byte_array_free (content, TRUE); - g_byte_array_free (sig, TRUE); + valid = openpgp_verify (cstream->buffer->data, cstream->buffer->len, + sigstream->buffer->data, sigstream->buffer->len, ex); + + camel_object_unref (CAMEL_OBJECT (sigstream)); + camel_object_unref (CAMEL_OBJECT (cstream)); return valid; } |