+2011-01-06 [pawel] 3.7.8cvs28
+
+ * src/export.c
+ * src/import.c
+ * src/messageview.c
+ * src/prefs_actions.c
+ * src/procmime.c
+ * src/gtk/gtkaspell.c
+ * src/plugins/pgpinline/pgpinline.c
+ * src/plugins/pgpmime/pgpmime.c
+ * src/plugins/smime/smime.c
+ Fix memory/file descriptors leaks
+
2011-01-06 [paul] 3.7.8cvs27
* src/plugins/pgpcore/sgpgme.c
( cvs diff -u -r 1.8.2.14 -r 1.8.2.15 src/unmime.c; ) > 3.7.8cvs25.patchset
( cvs diff -u -r 1.8.2.15 -r 1.8.2.16 src/unmime.c; ) > 3.7.8cvs26.patchset
( cvs diff -u -r 1.1.2.66 -r 1.1.2.67 src/plugins/pgpcore/sgpgme.c; ) > 3.7.8cvs27.patchset
+( cvs diff -u -r 1.8.2.29 -r 1.8.2.30 src/export.c; cvs diff -u -r 1.13.2.28 -r 1.13.2.29 src/import.c; cvs diff -u -r 1.94.2.210 -r 1.94.2.211 src/messageview.c; cvs diff -u -r 1.60.2.71 -r 1.60.2.72 src/prefs_actions.c; cvs diff -u -r 1.49.2.134 -r 1.49.2.135 src/procmime.c; cvs diff -u -r 1.9.2.70 -r 1.9.2.71 src/gtk/gtkaspell.c; cvs diff -u -r 1.1.2.45 -r 1.1.2.46 src/plugins/pgpinline/pgpinline.c; cvs diff -u -r 1.1.2.56 -r 1.1.2.57 src/plugins/pgpmime/pgpmime.c; cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/smime/smime.c; ) > 3.7.8cvs28.patchset
MICRO_VERSION=8
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=27
+EXTRA_VERSION=28
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
if (!src) {
alertpanel_error(_("Couldn't find the source folder."));
gtk_widget_grab_focus(src_entry);
+ g_free(mbox);
return;
} else {
export_ok = export_to_mbox(src, mbox);
if (!alt_gtkaspeller) {
gtkaspell_checkers_error_message(
g_strdup_printf(_("Couldn't initialize %s speller."), dictionary));
+ g_free(gtkaspell);
return NULL;
}
if (!broker) {
gtkaspell_checkers_error_message(
g_strdup(_("Couldn't initialize Enchant broker.")));
+ g_free(gtkaspeller);
return NULL;
}
if ((speller = set_dictionary(broker, dict)) == NULL) {
g_strdup_printf(_("Couldn't initialize %s dictionary:"), dict->fullname));
gtkaspell_checkers_error_message(
g_strdup(enchant_broker_get_error(broker)));
+ g_free(gtkaspeller);
return NULL;
}
gtkaspeller->speller = speller;
if (!dest) {
alertpanel_error(_("Can't find the destination folder."));
gtk_widget_grab_focus(dest_entry);
+ g_free(mbox);
return;
} else {
import_ok = proc_mbox(dest, mbox, FALSE, NULL);
addrp = addr;
/* write queue headers */
- if (fprintf(fp, "AF:\n"
+ ok=fprintf(fp, "AF:\n"
"NF:0\n"
"PS:10\n"
"SRH:1\n"
"R:<%s>\n",
account->address,
account->smtp_server?account->smtp_server:"",
- addrp) < 0) {
- g_free(addrp);
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ addrp);
g_free(addrp);
+ if (ok < 0)
+ goto FILE_ERROR;
/* check whether we need to save the message */
outbox = account_get_special_folder(account, F_OUTBOX);
outbox = NULL;
if (outbox) {
path = folder_item_get_identifier(outbox);
- if (fprintf(fp, "SCF:%s\n", path) < 0) {
- g_free(path);
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ ok = fprintf(fp, "SCF:%s\n", path);
g_free(path);
+
+ if (ok < 0)
+ goto FILE_ERROR;
}
- if (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "X-Claws-End-Special-Headers: 1\n") < 0)
+ goto FILE_ERROR;
/* Date */
get_rfc822_date(buf, sizeof(buf));
- if (fprintf(fp, "Date: %s\n", buf) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "Date: %s\n", buf) < 0)
+ goto FILE_ERROR;
/* From */
if (account->name && *account->name) {
notification_convert_header
(buf, sizeof(buf), account->name,
strlen("From: "));
- if (fprintf(fp, "From: %s <%s>\n", buf, account->address) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "From: %s <%s>\n", buf, account->address) < 0)
+ goto FILE_ERROR;
} else
- if (fprintf(fp, "From: %s\n", account->address) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
-
+ if (fprintf(fp, "From: %s\n", account->address) < 0)
+ goto FILE_ERROR;
- if (fprintf(fp, "To: %s\n", to) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "To: %s\n", to) < 0)
+ goto FILE_ERROR;
/* Subject */
notification_convert_header(buf, sizeof(buf), msginfo->subject,
strlen("Subject: "));
- if (fprintf(fp, "Subject: Disposition notification: %s\n", buf) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "Subject: Disposition notification: %s\n", buf) < 0)
+ goto FILE_ERROR;
/* Message ID */
if (account->set_domain && account->domain) {
}
generate_msgid(buf, sizeof(buf), addr);
- if (fprintf(fp, "Message-ID: <%s>\n", buf) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- return -1;
- }
+ if (fprintf(fp, "Message-ID: <%s>\n", buf) < 0)
+ goto FILE_ERROR;
}
boundary = generate_mime_boundary("DN");
qp_encode_line(enc_sub, (const guchar *)msginfo->subject);
g_strstrip(enc_sub);
}
- if (fprintf(fp, "MIME-Version: 1.0\n"
+ ok = fprintf(fp,"MIME-Version: 1.0\n"
"Content-Type: multipart/report; report-type=disposition-notification;\n"
" boundary=\"%s\"\n"
"\n"
orig_to?orig_to:"No To:",
account->address,
msginfo->msgid?msginfo->msgid:"NO MESSAGE ID",
- boundary) < 0) {
- fclose(fp);
- claws_unlink(tmp);
- g_free(boundary);
- return -1;
- }
+ boundary);
g_free(enc_sub);
g_free(orig_to);
g_free(date);
g_free(boundary);
+ if (ok < 0)
+ goto FILE_ERROR;
+
if (fclose(fp) == EOF) {
FILE_OP_ERROR(tmp, "fclose");
claws_unlink(tmp);
folder_item_remove_msg(queue, num);
return ok;
+
+FILE_ERROR:
+ fclose(fp);
+ claws_unlink(tmp);
+ return -1;
}
static gboolean find_encrypted_func(GNode *node, gpointer data)
if ((err = gpgme_new(&data->ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(textdata);
return 0;
}
gpgme_set_textmode(data->ctx, 1);
src_codeset) < 0) {
FILE_OP_ERROR(fname, "fprintf");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
/* Store any part before encrypted text */
if (fwrite(textdata, 1, pos - textdata, dstfp) < pos - textdata) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
dstfp) < strlen(_("\n--- Start of PGP/Inline encrypted data ---\n"))) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
chars = sgpgme_data_release_and_get_mem(plain, &len);
if (len > 0) {
if (fwrite(chars, 1, len, dstfp) < len) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
/* Store any part after encrypted text */
dstfp) < strlen(_("--- End of PGP/Inline encrypted data ---\n"))) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
if (pos != NULL) {
pos = strstr(pos, end_indicator);
if (fwrite(pos, 1, strlen(pos), dstfp) < strlen(pos)) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
}
gpgme_release(ctx);
return decinfo;
+
+FILE_ERROR:
+ fclose(dstfp);
+ g_free(fname);
+ gpgme_data_release(plain);
+ gpgme_release(ctx);
+ return NULL;
}
static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
i = 0;
if (err) {
debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
privacy_set_error(_("Couldn't add GPG key %s, %s"), fprs[i], gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
debug_print("found %s at %d\n", fprs[i], i);
if (!msgcontent->node->children) {
debug_print("msgcontent->node->children NULL, bailing\n");
privacy_set_error(_("Malformed message"));
+ g_free(kset);
return FALSE;
}
msgcontent = (MimeInfo *) msgcontent->node->children->data;
if (fp == NULL) {
privacy_set_error(_("Couldn't create temporary file, %s"), strerror(errno));
perror("my_tmpfile");
+ g_free(kset);
return FALSE;
}
procmime_write_mimeinfo(msgcontent, fp);
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
gpgme_set_armor(ctx, 1);
err = gpgme_op_encrypt(ctx, kset, GPGME_ENCRYPT_ALWAYS_TRUST, gpgtext, gpgenc);
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
+ g_free(kset);
if (enccontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
{
MimeInfo *msgcontent, *sigmultipart, *newinfo;
- gchar *textstr, *micalg;
+ gchar *textstr, *micalg = NULL;
FILE *fp;
gchar *boundary = NULL;
gchar *sigcontent;
if (sigcontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
privacy_set_error(_("Data signing failed, no contents."));
+ g_free(micalg);
return FALSE;
}
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
i = 0;
if (err) {
debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
privacy_set_error(_("Couldn't add GPG key %s, %s"), fprs[i], gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
debug_print("found %s at %d\n", fprs[i], i);
fp = my_tmpfile();
if (fp == NULL) {
privacy_set_error(_("Couldn't create temporary file, %s"), strerror(errno));
+ g_free(kset);
return FALSE;
}
procmime_write_mimeinfo(encmultipart, fp);
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
gpgme_data_release(gpgtext);
g_free(textstr);
+ g_free(kset);
if (enccontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");
if (len > 0) {
if (fwrite(chars, 1, len, dstfp) < len) {
FILE_OP_ERROR(fname, "fwrite");
+ fclose(dstfp);
g_free(fname);
g_free(chars);
gpgme_data_release(plain);
gboolean smime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
{
MimeInfo *msgcontent, *sigmultipart, *newinfo;
- gchar *textstr, *micalg;
+ gchar *textstr, *micalg = NULL;
FILE *fp;
gchar *boundary = NULL;
gchar *sigcontent;
if (!sigcontent) {
gpgme_release(ctx);
+ g_free(micalg);
return FALSE;
}
real_content = sigcontent+strlen("-----BEGIN SIGNED MESSAGE-----\n");
if (!strstr(real_content, "-----END SIGNED MESSAGE-----")) {
debug_print("missing end\n");
gpgme_release(ctx);
+ g_free(micalg);
return FALSE;
}
*strstr(real_content, "-----END SIGNED MESSAGE-----") = '\0';
fp = g_fopen(tmpfile, "wb");
if (fp == NULL) {
perror("get_tmp_file");
+ g_free(kset);
return FALSE;
}
procmime_decode_content(msgcontent);
fp = g_fopen(tmpfile, "rb");
if (fp == NULL) {
perror("get_tmp_file");
+ g_free(kset);
return FALSE;
}
g_free(tmpfile);
gpgme_op_encrypt(ctx, kset, GPGME_ENCRYPT_ALWAYS_TRUST, gpgtext, gpgenc);
gpgme_release(ctx);
+ g_free(kset);
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
if (!enccontent) {
fputc('\n', pfile->fp) == EOF) {
FILE_OP_ERROR(rcpath, "fputs || fputc");
prefs_file_close_revert(pfile);
+ g_free(act);
g_free(rcpath);
return;
}
while ((restlength > 0) && ((readlength = fread(buf, 1, restlength > BUFFSIZE ? BUFFSIZE : restlength, infp)) > 0)) {
if (fwrite(buf, 1, readlength, outfp) != readlength) {
saved_errno = errno;
+ fclose(infp);
fclose(outfp);
return -(saved_errno);
}