From 06d0ac5cfb2d71e3fab66d403b53b7d6080d48ce Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 28 Sep 2007 05:47:28 +0000 Subject: fixed the crash when try to use ascii-armored PGP encryption. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1917 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 6 ++++++ ChangeLog.ja | 6 ++++++ NEWS | 1 + src/compose.c | 54 ++++++++++++++++++++++++++++++++---------------------- src/select-keys.c | 2 ++ 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49450749..96425c36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-28 + + * src/compose.c + src/select-keys.c: fixed the crash when try to use ascii-armored PGP + encryption. + 2007-09-27 * libsylph/folder.c: folder_item_compare(): fixed a bug that virtual diff --git a/ChangeLog.ja b/ChangeLog.ja index 3c3054df..5f5cf06c 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,9 @@ +2007-09-28 + + * src/compose.c + src/select-keys.c: ASCII 包装 PGP 暗号化使用時にクラッシュするバグを + 修正。 + 2007-09-27 * libsylph/folder.c: folder_item_compare(): 仮想フォルダが正しく diff --git a/NEWS b/NEWS index c0e6a8f9..f2085bca 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Changes of Sylpheed * The status label is automatically resized now when there is not enough width. * The bug that virtual folders were not sorted properly was fixed. + * The crash when trying to use ascii-armored PGP encryption was fixed. * 2.4.6 (stable) diff --git a/src/compose.c b/src/compose.c index 5b453336..71691daf 100644 --- a/src/compose.c +++ b/src/compose.c @@ -3252,32 +3252,13 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, } if (rfc2015_is_available() && !is_draft) { - gint ret; - - if (compose->use_encryption && compose->account->ascii_armored) { - if (compose->use_signing) - ret = compose_encrypt_sign_armored(compose, &buf); - else - ret = compose_encrypt_armored(compose, &buf); - if (ret < 0) { - g_warning("ascii-armored encryption failed\n"); - fclose(fp); - g_unlink(file); - g_free(buf); - return -1; - } - } else if (compose->use_signing && compose->account->clearsign) { + if ((compose->use_encryption && + compose->account->ascii_armored) || + (compose->use_signing && compose->account->clearsign)) { /* MIME encoding doesn't fit with cleartext signature */ if (encoding == ENC_QUOTED_PRINTABLE || encoding == ENC_BASE64) encoding = ENC_8BIT; - if (compose_clearsign_text(compose, &buf) < 0) { - g_warning("clearsign failed\n"); - fclose(fp); - g_unlink(file); - g_free(buf); - return -1; - } } } #endif @@ -3322,6 +3303,35 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, return -1; } +#if USE_GPGME + /* do ascii-armor encryption and/or clearsign */ + if (rfc2015_is_available() && !is_draft) { + gint ret; + + if (compose->use_encryption && compose->account->ascii_armored) { + if (compose->use_signing) + ret = compose_encrypt_sign_armored(compose, &buf); + else + ret = compose_encrypt_armored(compose, &buf); + if (ret < 0) { + g_warning("ascii-armored encryption failed\n"); + fclose(fp); + g_unlink(file); + g_free(buf); + return -1; + } + } else if (compose->use_signing && compose->account->clearsign) { + if (compose_clearsign_text(compose, &buf) < 0) { + g_warning("clearsign failed\n"); + fclose(fp); + g_unlink(file); + g_free(buf); + return -1; + } + } + } +#endif + if (compose->use_attach && gtk_tree_model_iter_n_children(model, NULL) > 0) { #if USE_GPGME diff --git a/src/select-keys.c b/src/select-keys.c index e5976569..d8394a93 100644 --- a/src/select-keys.c +++ b/src/select-keys.c @@ -101,6 +101,8 @@ update_progress (struct select_keys_s *sk, int running, const char *pattern) static int windmill[] = { '-', '\\', '|', '/' }; char *buf; + if (!pattern) + pattern = ""; if (!running) buf = g_strdup_printf (_("Please select key for `%s'"), pattern); -- cgit v1.2.3