diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-01-22 06:35:08 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-01-22 06:35:08 +0800 |
commit | fb4e03c0af0e3a2fb086a186600db631c388ed66 (patch) | |
tree | 64b6a7bf90c42526ac065e99d02a3e159fe14fe9 /mail | |
parent | 6269637d7226d702fd05c4cdb6160adab0e18718 (diff) | |
download | gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar.gz gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar.bz2 gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar.lz gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar.xz gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.tar.zst gsoc2013-evolution-fb4e03c0af0e3a2fb086a186600db631c388ed66.zip |
Don't forget to unref the filters. (pgp_mime_part_verify): Same.
2001-01-21 Jeffrey Stedfast <fejj@ximian.com>
* mail-crypto.c (pgp_mime_part_sign): Don't forget to unref the
filters.
(pgp_mime_part_verify): Same.
(pgp_mime_part_encrypt): Same.
(pgp_mime_part_decrypt): Take NotZed's advice and use
camel_stream_mem_new_with_buffer instead of writing to a new
stream_mem. Also use camel_data_wrapper_construct_from_stream
instead of creating a parser and using that.
svn path=/trunk/; revision=7687
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/mail-crypto.c | 48 |
2 files changed, 32 insertions, 27 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 81998a3cea..0726c67148 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,16 @@ 2001-01-21 Jeffrey Stedfast <fejj@ximian.com> + * mail-crypto.c (pgp_mime_part_sign): Don't forget to unref the + filters. + (pgp_mime_part_verify): Same. + (pgp_mime_part_encrypt): Same. + (pgp_mime_part_decrypt): Take NotZed's advice and use + camel_stream_mem_new_with_buffer instead of writing to a new + stream_mem. Also use camel_data_wrapper_construct_from_stream + instead of creating a parser and using that. + +2001-01-21 Jeffrey Stedfast <fejj@ximian.com> + * mail-crypto.c: Updated header comment and fixed some ref/unref count problems in the various functions. Also fixed some other little things. diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index 2ddd5ab6d1..7f1a34c54b 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -158,10 +158,9 @@ pgp_mime_part_sign (CamelMimePart **mime_part, const gchar *userid, PgpHashType CamelStreamFilter *filtered_stream; CamelMimeFilter *crlf_filter, *from_filter; CamelStream *stream; - GByteArray *array; - gchar *cleartext, *signature; + GByteArray *content; + gchar *signature; gchar *hash_type = NULL; - gint clearlen; g_return_if_fail (*mime_part != NULL); g_return_if_fail (CAMEL_IS_MIME_PART (*mime_part)); @@ -176,24 +175,24 @@ pgp_mime_part_sign (CamelMimePart **mime_part, const gchar *userid, PgpHashType camel_mime_part_set_encoding (part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE); /* get the cleartext */ - array = g_byte_array_new (); + content = g_byte_array_new (); stream = camel_stream_mem_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), array); + 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); from_filter = CAMEL_MIME_FILTER (camel_mime_filter_from_new ()); filtered_stream = camel_stream_filter_new_with_stream (stream); camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlf_filter)); + camel_object_unref (CAMEL_OBJECT (crlf_filter)); camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (from_filter)); + camel_object_unref (CAMEL_OBJECT (from_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)); - cleartext = array->data; - clearlen = array->len; /* get the signature */ - signature = openpgp_sign (cleartext, clearlen, userid, hash, ex); - g_byte_array_free (array, TRUE); + signature = openpgp_sign (content->data, content->len, userid, hash, ex); + g_byte_array_free (content, TRUE); if (camel_exception_is_set (ex)) { /* restore the original encoding */ camel_mime_part_set_encoding (part, encoding); @@ -282,6 +281,7 @@ pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); filtered_stream = camel_stream_filter_new_with_stream (stream); 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)); @@ -323,7 +323,7 @@ pgp_mime_part_encrypt (CamelMimePart **mime_part, const GPtrArray *recipients, C CamelStreamFilter *filtered_stream; CamelMimeFilter *crlf_filter; CamelStream *stream; - GByteArray *contents; + GByteArray *content; gchar *ciphertext; g_return_if_fail (*mime_part != NULL); @@ -333,21 +333,23 @@ pgp_mime_part_encrypt (CamelMimePart **mime_part, const GPtrArray *recipients, C part = *mime_part; /* get the contents */ - contents = g_byte_array_new (); + content = g_byte_array_new (); stream = camel_stream_mem_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), contents); + 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); 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)); /* pgp encrypt */ - ciphertext = openpgp_encrypt (contents->data, - contents->len, + ciphertext = openpgp_encrypt (content->data, + content->len, recipients, FALSE, NULL, ex); + g_byte_array_free (content, TRUE); if (camel_exception_is_set (ex)) return; @@ -399,13 +401,12 @@ pgp_mime_part_decrypt (CamelMimePart *mime_part, CamelException *ex) { CamelDataWrapper *wrapper; CamelMultipart *multipart; - CamelMimeParser *parser; CamelMimePart *encrypted_part, *part; CamelContentType *mime_type; CamelStream *stream; GByteArray *content; - gchar *cleartext, *ciphertext = NULL; - int cipherlen, clearlen; + gchar *cleartext; + int clearlen; g_return_val_if_fail (mime_part != NULL, NULL); g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL); @@ -429,27 +430,20 @@ pgp_mime_part_decrypt (CamelMimePart *mime_part, CamelException *ex) camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), content); camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (encrypted_part), stream); camel_object_unref (CAMEL_OBJECT (stream)); - ciphertext = content->data; - cipherlen = content->len; /* get the cleartext */ - cleartext = openpgp_decrypt (ciphertext, cipherlen, &clearlen, ex); + cleartext = openpgp_decrypt (content->data, content->len, &clearlen, ex); g_byte_array_free (content, TRUE); if (camel_exception_is_set (ex)) return NULL; /* create a stream based on the returned cleartext */ - stream = camel_stream_mem_new (); - camel_stream_write (stream, cleartext, clearlen); - camel_stream_reset (stream); + stream = camel_stream_mem_new_with_buffer (cleartext, clearlen); g_free (cleartext); /* construct the new decrypted mime part from the stream */ part = camel_mime_part_new (); - parser = camel_mime_parser_new (); - camel_mime_parser_init_with_stream (parser, stream); - camel_mime_part_construct_from_parser (part, parser); - camel_object_unref (CAMEL_OBJECT (parser)); + camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (part), stream); camel_object_unref (CAMEL_OBJECT (stream)); return part; |