+2009-03-10 18:39 +0100 NONAKA Kimihiro <nonakap@gmail.com> (cc6fede605d4)
+
+ * ChangeLog, mh.c: Fix crashes with 64bit time_t. Closes #3184.
+
2009-03-09 12:04 +0100 Vincent Lefevre <vincent@vinc17.org> (4ce562b7f5d7)
* mbyte.h: Unbreak compilation on OS X with --with-regex/--without-wc-
recode_buf (buf, sizeof (buf));
write_safe_address (rc, buf);
fputc ('\n', rc);
- fclose (rc);
+ safe_fclose (&rc);
mutt_message _("Alias added.");
}
else
fseek_err:
mutt_perror (_("Error seeking in alias file"));
- fclose(rc);
+ safe_fclose (&rc);
return;
}
else
mutt_perror(fpin ? tempfile : a->filename);
- if(fpin) fclose(fpin);
- if(fpout) fclose(fpout);
+ if(fpin) safe_fclose (&fpin);
+ if(fpout) safe_fclose (&fpout);
return a->unlink ? 0 : -1;
}
goto bailout;
}
mutt_copy_stream (fp, tfp);
- fclose (fp);
- fclose (tfp);
+ safe_fclose (&fp);
+ safe_fclose (&tfp);
mutt_unlink (a->filename);
if (mutt_rename_file (tempfile, a->filename) != 0)
{
if (stat (m->filename, &st) == -1)
{
mutt_perror ("stat");
- fclose (s.fpout);
+ safe_fclose (&s.fpout);
return (-1);
}
mutt_body_handler (m, &s);
- fclose (s.fpout);
+ safe_fclose (&s.fpout);
if (fp == NULL)
{
m->length = 0;
m->parts = saved_parts;
m->hdr = saved_hdr;
}
- fclose (s.fpin);
+ safe_fclose (&s.fpin);
}
return (0);
if ((f = fopen (path, "rb")))
{
rc = test_last_status_new (f);
- fclose (f);
+ safe_fclose (&f);
}
return rc;
}
do_check '\<fopen.*'\"'.*w' __FOPEN_CHECKED__ "Alert: Unchecked fopen calls."
+do_check '\<fclose.*'\"'.*w' __FCLOSE_CHECKED__ "Alert: Unchecked fclose calls."
do_check '\<(mutt_)?strcpy' __STRCPY_CHECKED__ "Alert: Unchecked strcpy calls."
do_check '\<strcat' __STRCAT_CHECKED__ "Alert: Unchecked strcat calls."
do_check '\<sprintf.*%s' __SPRINTF_CHECKED__ "Alert: Unchecked sprintf calls."
}
pipe_msg (h, fpout, decode, print);
- fclose (fpout);
+ safe_fclose (&fpout);
rc = mutt_wait_filter (thepid);
}
else
FREE (&idx[idxlen]);
continue;
}
- fclose (fp);
+ safe_fclose (&fp);
if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL)
{
fseeko (fp, cur->offset, 0);
if (mutt_copy_bytes (fp, fpout, cur->length) == -1)
{
- fclose (fp);
+ safe_fclose (&fp);
mutt_free_body (&cur);
return (-1);
}
mutt_free_body (&cur);
- fclose (fp);
+ safe_fclose (&fp);
}
else
{
buf[0] = c;
gpgme_data_write (data, buf, 1);
}
- fclose(fptmp);
+ safe_fclose (&fptmp);
gpgme_data_seek (data, 0, SEEK_SET);
}
else
{
- fclose(fptmp);
+ safe_fclose (&fptmp);
err = gpgme_data_new_from_file (&data, tempfile, 1);
}
unlink (tempfile);
if (fwrite (buf, nread, 1, fp) != 1)
{
mutt_perror (tempfile);
- fclose (fp);
+ safe_fclose (&fp);
unlink (tempfile);
return NULL;
}
if (ret_fp)
rewind (fp);
else
- fclose (fp);
+ safe_fclose (&fp);
if (nread == -1)
{
mutt_error (_("error reading data object: %s\n"), gpgme_strerror (err));
unlink (tempfile);
- fclose (fp);
+ safe_fclose (&fp);
return NULL;
}
if (ret_fp)
b->type = saved_b_type;
b->length = saved_b_length;
b->offset = saved_b_offset;
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
rewind (*fpout);
if (*cur && !is_signed && !(*cur)->parts && mutt_is_application_smime (*cur))
{
bb->length = ftello (s.fpout);
bb->offset = 0;
rewind (tmpfp);
- fclose (*fpout);
+ safe_fclose (fpout);
memset (&s, 0, sizeof (s));
s.fpin = tmpfp;
bb->type = saved_b_type;
bb->length = saved_b_length;
bb->offset = saved_b_offset;
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
rewind (*fpout);
mutt_free_body (cur);
*cur = tmp_b;
err_fp:
if (rc)
- {
- fclose (*fp);
- *fp = NULL;
- }
+ safe_fclose (fp);
err_tmpdir:
if (dryrun)
mutt_rmtree (tmpdir);
dprint (1, (debugfile, "error converting key file into data object\n"));
return;
}
- fclose (in);
+ safe_fclose (&in);
if (!pgp_gpgme_extract_keys (keydata, &out, 0))
{
outlen = ftell (out);
fseek (out, 0, SEEK_SET);
mutt_copy_bytes (out, stdout, outlen);
- fclose (out);
+ safe_fclose (&out);
}
else
printf (_("Error extracting key data!\n"));
}
fgetconv_close (&fc);
- fclose (fp);
+ safe_fclose (&fp);
}
mutt_free_body (&tattach);
}
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_unlink(tempfile);
dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
mutt_free_body (&tattach);
}
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_unlink(tempfile);
dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
leave:
gpgme_key_release (k);
gpgme_release (listctx);
- fclose (fp);
+ safe_fclose (&fp);
mutt_clear_error ();
snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), crypt_keyid (key));
mutt_do_pager (cmd, tempfile, 0, NULL);
fputc (c, fp);
}
- fclose (fp);
+ safe_fclose (&fp);
return 0;
}
if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
!crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->security))
{
- fclose (fpout);
+ safe_fclose (&fpout);
break;
}
}
}
- fclose (fpout);
+ safe_fclose (&fpout);
if (isendwin())
mutt_any_key_to_continue (NULL);
snprintf(tmp, sizeof(tmp), "\"%s\" %lu bytes\n", path, (unsigned long) sb.st_size);
addstr(tmp);
}
- fclose (f);
+ safe_fclose (&f);
}
else
{
mx_close_mailbox (&tmpctx, NULL);
bail:
- if (fp) fclose (fp);
+ if (fp) safe_fclose (&fp);
if (rc >= 0)
unlink (tmp);
if (ferror (fp))
mutt_perror ("fgets");
- fclose (fp);
+ safe_fclose (&fp);
mutt_wait_filter (thepid);
close (devnull);
{
b->length = ftello (s->fpout);
b->offset = 0;
- fclose (s->fpout);
+ safe_fclose (&s->fpout);
/* restore final destination and substitute the tempfile for input */
s->fpout = fp;
b->offset = tmpoffset;
/* restore the original source stream */
- fclose (s->fpin);
+ safe_fclose (&s->fpin);
s->fpin = fp;
}
}
mutt_copy_stream (ifp, ofp);
- fclose (ifp);
- fclose (ofp);
+ safe_fclose (&ifp);
+ safe_fclose (&ofp);
if (stat (path, &st) == -1)
{
if ((ofp = safe_fopen (body, "w")) == NULL)
{
/* intentionally leak a possible temporary file here */
- fclose (ifp);
+ safe_fclose (&ifp);
mutt_perror (body);
return;
}
n = mutt_read_rfc822_header (ifp, NULL, 1, 0);
while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0)
fwrite (buffer, 1, i, ofp);
- fclose (ofp);
- fclose (ifp);
+ safe_fclose (&ofp);
+ safe_fclose (&ifp);
mutt_unlink (path);
/* restore old info. */
if (menu != MENU_PAGER)
dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
- fclose (f);
+ safe_fclose (&f);
snprintf (buf, sizeof (buf), _("Help for %s"), desc);
}
}
}
- fclose (f);
+ safe_fclose (&f);
FREE (&linebuf);
}
}
cleanup:
- fclose (f);
+ safe_fclose (&f);
FREE (&linebuf);
if (tmp != NULL)
{
{
rewind (tmp);
mutt_copy_stream (tmp, f);
- fclose (f);
+ safe_fclose (&f);
}
- fclose (tmp);
+ safe_fclose (&tmp);
unlink (tmpfname);
}
}
}
fputs ("|\n", f);
- fclose (f);
+ safe_fclose (&f);
FREE (&tmp);
if (--n < 0)
if (h.data)
imap_free_header_data ((void**) (void*) &h.data);
imap_hcache_close (idata);
- fclose (fp);
+ safe_fclose (&fp);
return -1;
}
}
#if USE_HCACHE
imap_hcache_close (idata);
#endif
- fclose (fp);
+ safe_fclose (&fp);
return -1;
}
imap_hcache_close (idata);
#endif /* USE_HCACHE */
- fclose(fp);
+ safe_fclose (&fp);
if (ctx->msgcount > oldmsgcount)
{
pc = imap_next_word (pc);
mutt_error ("%s", pc);
mutt_sleep (1);
- fclose (fp);
+ safe_fclose (&fp);
goto fail;
}
flush_buffer(buf, &len, idata->conn);
mutt_socket_write (idata->conn, "\r\n");
- fclose (fp);
+ safe_fclose (&fp);
do
rc = imap_cmd_step (idata);
/* read line */
memset (&expn, 0, sizeof (expn));
expn.data = mutt_read_line (NULL, &expn.dsize, fp, &line);
- fclose (fp);
+ safe_fclose (&fp);
mutt_wait_filter (pid);
/* if we got output, make a new string consiting of the shell ouptput
}
FREE (&token.data);
FREE (&linebuf);
- fclose (f);
+ safe_fclose (&f);
if (pid != -1)
mutt_wait_filter (pid);
if (rc)
if (fflush (*f) || fsync (fileno (*f)))
{
r = -1;
- fclose (*f);
+ safe_fclose (f);
}
else
- r = fclose(*f);
- *f = NULL;
+ r = safe_fclose (f);
}
return r;
fwrite (buf, 1, MIN (sizeof (buf), sb.st_size), f);
sb.st_size -= MIN (sizeof (buf), sb.st_size);
}
- fclose (f);
+ safe_fclose (&f);
}
}
}
if (!option (OPTNOCURSES))
mutt_endwin (NULL);
perror (tempfile);
- fclose (fin);
+ safe_fclose (&fin);
FREE (&tempfile);
exit (1);
}
mutt_copy_stream (fin, fout);
else if (bodytext)
fputs (bodytext, fout);
- fclose (fout);
+ safe_fclose (&fout);
if (fin && fin != stdin)
- fclose (fin);
+ safe_fclose (&fin);
}
}
if (fclose (fp) != 0)
{
fp = NULL;
- dprint(1, (debugfile, "mbox_sync_mailbox: fclose() returned non-zero.\n"));
+ dprint(1, (debugfile, "mbox_sync_mailbox: safe_fclose (&) returned non-zero.\n"));
unlink (tempfile);
mutt_perror (tempfile);
mutt_sleep (5);
}
}
- fclose (fp);
+ safe_fclose (&fp);
fp = NULL;
mbox_unlock_mailbox (ctx);
h->env = mutt_read_rfc822_header (f, h, 0, 0);
fstat (fileno (f), &st);
- fclose (f);
+ safe_fclose (&f);
if (!h->received)
h->received = h->date_sent;
if (!X509_digest (peercert, EVP_sha1(), peermd, &peermdlen))
{
- fclose (fp);
+ safe_fclose (&fp);
return 0;
}
break;
}
X509_free (cert);
- fclose (fp);
+ safe_fclose (&fp);
return pass;
}
{
if (PEM_write_X509 (fp, cert))
done = 1;
- fclose (fp);
+ safe_fclose (&fp);
}
if (!done)
{
}
b64_data.size = fread(b64_data.data, 1, b64_data.size, fd1);
- fclose(fd1);
+ safe_fclose (&fd1);
do {
ret = gnutls_pem_base64_decode_alloc(NULL, &b64_data, &cert);
{
regfree(&preg);
FREE(&linestr);
- fclose(fp);
+ safe_fclose (&fp);
return 1;
}
}
}
regfree(&preg);
- fclose(fp);
+ safe_fclose (&fp);
}
/* not found a matching name */
gnutls_free (pemdata.data);
}
}
- fclose (fp);
+ safe_fclose (&fp);
}
if (!done)
{
if ((pid = mutt_create_filter(command->data, NULL, &filter, NULL)))
{
n = fread(dest, 1, destlen /* already decremented */, filter);
- fclose(filter);
+ safe_fclose (&filter);
dest[n] = '\0';
while (dest[n-1] == '\n' || dest[n-1] == '\r')
dest[--n] = '\0';
if (stat (fname, &sb) != 0)
{
mutt_perror (fname);
- fclose (fp);
+ safe_fclose (&fp);
return (-1);
}
unlink (fname);
}
}
- fclose (fp);
+ safe_fclose (&fp);
if (IsHeader (extra))
{
Context->msgnotreadyet = -1;
mx_close_message (&msg);
if (s.fpout)
{
- fclose (s.fpout);
+ safe_fclose (&s.fpout);
unlink (tempfile);
}
return (0);
if (option (OPTTHOROUGHSRC))
{
- fclose (fp);
+ safe_fclose (&fp);
unlink (tempfile);
}
}
fseeko (s->fpin, sigbdy->offset, 0);
mutt_copy_bytes (s->fpin, fp, sigbdy->length);
- fclose (fp);
+ safe_fclose (&fp);
mutt_mktemp(pgperrfile);
if(!(pgperr = safe_fopen(pgperrfile, "w+")))
if (Context->hdrs[Context->v2r[i]]->security & PGPENCRYPT
&& !pgp_valid_passphrase())
{
- fclose (fpout);
+ safe_fclose (&fpout);
goto bailout;
}
mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
mutt_parse_mime_message (Context, h);
if (h->security & PGPENCRYPT && !pgp_valid_passphrase())
{
- fclose (fpout);
+ safe_fclose (&fpout);
goto bailout;
}
mutt_copy_message (fpout, Context, h, M_CM_DECODE|M_CM_CHARCONV, 0);
}
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_endwin (NULL);
pgp_invoke_import (tempfname);
mutt_any_key_to_continue (NULL);
mutt_body_handler (top, &s);
- fclose (tempfp);
+ safe_fclose (&tempfp);
pgp_invoke_import (tempfname);
mutt_any_key_to_continue (NULL);
if((pgptmp = safe_fopen (pgptmpfile, "w")) == NULL)
{
mutt_perror (pgptmpfile);
- fclose(pgperr);
+ safe_fclose (&pgperr);
return NULL;
}
fseeko (s->fpin, a->offset, 0);
mutt_copy_bytes (s->fpin, pgptmp, a->length);
- fclose (pgptmp);
+ safe_fclose (&pgptmp);
if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1,
fileno (pgperr), pgptmpfile)) == -1)
{
- fclose (pgperr);
+ safe_fclose (&pgperr);
unlink (pgptmpfile);
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: could not create a PGP subprocess! --]\n\n"), s);
if (!pgp_use_gpg_agent())
fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
- fclose(pgpin);
+ safe_fclose (&pgpin);
/* Read the output from PGP, and make sure to change CRLF to LF, otherwise
* read_mime_header has a hard time parsing the message.
fputs (buf, fpout);
}
- fclose (pgpout);
+ safe_fclose (&pgpout);
rv = mutt_wait_filter (thepid);
mutt_unlink(pgptmpfile);
p->goodsig = 0;
state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
}
- fclose (pgperr);
+ safe_fclose (&pgperr);
fflush (fpout);
rewind (fpout);
rc = -1;
}
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_unlink(tempfile);
return rc;
if ((sfp = safe_fopen(signedfile, "w")) == NULL)
{
mutt_perror(signedfile);
- fclose(fp);
+ safe_fclose (&fp);
unlink(sigfile);
return NULL;
}
mutt_write_mime_header (a, sfp);
fputc ('\n', sfp);
mutt_write_mime_body (a, sfp);
- fclose(sfp);
+ safe_fclose (&sfp);
if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr,
-1, -1, -1, signedfile)) == -1)
{
mutt_perror _("Can't open PGP subprocess!");
- fclose(fp);
+ safe_fclose (&fp);
unlink(sigfile);
unlink(signedfile);
return NULL;
if (!pgp_use_gpg_agent())
fputs(PgpPass, pgpin);
fputc('\n', pgpin);
- fclose(pgpin);
+ safe_fclose (&pgpin);
/*
* Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as
if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
empty=1;
- fclose (pgperr);
- fclose (pgpout);
+ safe_fclose (&pgperr);
+ safe_fclose (&pgpout);
unlink (signedfile);
if (fclose (fp) != 0)
{
mutt_perror (pgperrfile);
unlink(tempfile);
- fclose(fpout);
+ safe_fclose (&fpout);
return NULL;
}
unlink (pgperrfile);
{
mutt_perror(pgpinfile);
unlink(tempfile);
- fclose(fpout);
- fclose(pgperr);
+ safe_fclose (&fpout);
+ safe_fclose (&pgperr);
return NULL;
}
mutt_write_mime_header (a, fptmp);
fputc ('\n', fptmp);
mutt_write_mime_body (a, fptmp);
- fclose(fptmp);
+ safe_fclose (&fptmp);
if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1,
fileno (fpout), fileno (pgperr),
pgpinfile, keylist, sign)) == -1)
{
- fclose (pgperr);
+ safe_fclose (&pgperr);
unlink(pgpinfile);
return (NULL);
}
fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
}
- fclose(pgpin);
+ safe_fclose (&pgpin);
if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
empty=1;
rewind (fpout);
if(!empty)
empty = (fgetc (fpout) == EOF);
- fclose (fpout);
+ safe_fclose (&fpout);
fflush (pgperr);
rewind (pgperr);
err = 1;
fputs (buf, stdout);
}
- fclose (pgperr);
+ safe_fclose (&pgperr);
/* pause if there is any error output from PGP */
if (err)
if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL)
{
mutt_perror (pgpinfile);
- fclose (fp);
+ safe_fclose (&fp);
return NULL;
}
mutt_copy_stream (fp, pgpin);
}
safe_fclose (&fp);
- fclose (pgpin);
+ safe_fclose (&pgpin);
mutt_mktemp (pgpoutfile);
mutt_mktemp (pgperrfile);
unlink (pgpinfile);
if (pgpout)
{
- fclose (pgpout);
+ safe_fclose (&pgpout);
unlink (pgpoutfile);
}
return NULL;
pgpinfile, keylist, flags)) == -1)
{
mutt_perror _("Can't invoke PGP");
- fclose (pgpout);
- fclose (pgperr);
+ safe_fclose (&pgpout);
+ safe_fclose (&pgperr);
mutt_unlink (pgpinfile);
unlink (pgpoutfile);
return NULL;
*PgpPass = 0;
if (flags & SIGN)
fprintf (pgpin, "%s\n", PgpPass);
- fclose (pgpin);
+ safe_fclose (&pgpin);
if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT))
empty=1;
if(!empty)
empty = (fgetc (pgpout) == EOF);
- fclose (pgpout);
+ safe_fclose (&pgpout);
err = 0;
fputs (buff, stdout);
}
- fclose (pgperr);
+ safe_fclose (&pgperr);
if (err)
mutt_any_key_to_continue (NULL);
}
if ((fp = safe_fopen (tempfile, "w")) == NULL)
{
- fclose (devnull);
+ safe_fclose (&devnull);
mutt_perror _("Can't create temporary file");
break;
}
{
mutt_perror _("Can't create filter");
unlink (tempfile);
- fclose (fp);
- fclose (devnull);
+ safe_fclose (&fp);
+ safe_fclose (&devnull);
}
mutt_wait_filter (thepid);
- fclose (fp);
- fclose (devnull);
+ safe_fclose (&fp);
+ safe_fclose (&devnull);
mutt_clear_error ();
snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"),
pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent)));
if ((devnull = fopen ("/dev/null", "w")) == NULL) /* __FOPEN_CHECKED__ */
{
mutt_perror _("Can't open /dev/null");
- fclose (tempfp);
+ safe_fclose (&tempfp);
if (tempf == tempfb)
unlink (tempf);
return NULL;
{
mutt_perror _("Can't create filter");
unlink (tempf);
- fclose (tempfp);
- fclose (devnull);
+ safe_fclose (&tempfp);
+ safe_fclose (&devnull);
return NULL;
}
mutt_wait_filter (thepid);
- fclose (tempfp);
- fclose (devnull);
+ safe_fclose (&tempfp);
+ safe_fclose (&devnull);
att = mutt_new_body ();
att->filename = safe_strdup (tempf);
FGETPOS(rfp,pos);
}
- fclose (rfp);
+ safe_fclose (&rfp);
}
}
}
- fclose (f);
+ safe_fclose (&f);
unlink (tempfile);
return ret;
}
bail:
/* that's it. */
- if (bfp != fp) fclose (bfp);
+ if (bfp != fp) safe_fclose (&bfp);
if (msg) mx_close_message (&msg);
if (rv == -1)
}
}
FREE (&buf);
- fclose (fp);
+ safe_fclose (&fp);
if (mutt_wait_filter (thepid))
{
dprint (1, (debugfile, "Error: %s\n", msg));
if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
{
fprintf(fpout, "%s", AttachSep);
- fclose (fpout);
+ safe_fclose (&fpout);
}
}
else
if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL)
{
fprintf(fpout, "%s", AttachSep);
- fclose (fpout);
+ safe_fclose (&fpout);
}
}
}
return;
}
mutt_copy_stream (ifp, state->fpout);
- fclose (ifp);
+ safe_fclose (&ifp);
if (AttachSep)
state_puts (AttachSep, state);
}
mutt_endwin (NULL);
thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
pipe_attachment_list (buf, fp, tag, top, filter, &state);
- fclose (state.fpout);
+ safe_fclose (&state.fpout);
if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
mutt_any_key_to_continue (NULL);
}
if ((ifp = fopen (newfile, "r")) != NULL)
{
mutt_copy_stream (ifp, state->fpout);
- fclose (ifp);
+ safe_fclose (&ifp);
if (AttachSep)
state_puts (AttachSep, state);
}
memset (&state, 0, sizeof (STATE));
thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
print_attachment_list (fp, tag, top, &state);
- fclose (state.fpout);
+ safe_fclose (&state.fpout);
if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
mutt_any_key_to_continue (NULL);
}
if (WithCrypto && need_secured && secured)
{
- fclose (fp);
+ safe_fclose (&fp);
mutt_free_body (&cur);
}
mutt_forward_trailer (tmpfp);
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
tmpfp = NULL;
/* now that we have the template, send it. */
if (tmpfp)
{
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
mutt_unlink (tmpbody);
}
}
}
}
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
}
else if (rc == M_YES) /* do MIME encapsulation - we don't need to do much here */
{
copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL)
{
mutt_free_header (&tmphdr);
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
return;
}
}
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent) == 0)
mutt_set_flag (Context, hdr, M_REPLIED, 1);
}
}
} /* while (!found && (buf = mutt_read_line ())) */
- fclose (fp);
+ safe_fclose (&fp);
} /* if ((fp = fopen ())) */
FREE (&buf);
return found;
return 3;
if ((nfp = safe_fopen (newfile,"w")) == NULL)
{
- fclose(ofp);
+ safe_fclose (&ofp);
return 3;
}
mutt_copy_stream (ofp,nfp);
- fclose (nfp);
- fclose (ofp);
+ safe_fclose (&nfp);
+ safe_fclose (&ofp);
mutt_unlink (oldfile);
return 0;
}
mutt_mktemp (tmpfile);
if ((out = safe_fopen (tmpfile, "w+")) == NULL)
{
- fclose (in);
+ safe_fclose (&in);
return;
}
}
fputs (buf, out);
}
- fclose (in);
- fclose (out);
+ safe_fclose (&in);
+ safe_fclose (&out);
mutt_set_mtime (hdr->content->filename, tmpfile);
unlink (hdr->content->filename);
mutt_str_replace (&hdr->content->filename, tmpfile);
if (option (OPTSIGDASHES))
fputs ("\n-- \n", f);
mutt_copy_stream (tmpfp, f);
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
if (thepid != -1)
mutt_wait_filter (thepid);
}
if ((mutt_write_mime_body (msg->content, tempfp) == -1))
{
- fclose(tempfp);
+ safe_fclose (&tempfp);
unlink (tempfile);
return (-1);
}
mutt_copy_stream (fpin, f);
fgetconv_close (&fc);
- fclose (fpin);
+ safe_fclose (&fpin);
return (ferror (f) ? -1 : 0);
}
p = NULL;
}
}
- fclose (f);
+ safe_fclose (&f);
}
}
if (stat (a->filename, &sb) == -1)
{
mutt_perror ("stat");
- fclose (fpin);
+ safe_fclose (&fpin);
}
a->length = sb.st_size;
}
FREE (&line);
if (fpin && !fp)
- fclose (fpin);
+ safe_fclose (&fpin);
if (fpout)
- fclose (fpout);
+ safe_fclose (&fpout);
else
return;
}
s.fpin = fpin;
mutt_decode_attachment (a, &s);
- fclose (s.fpout);
+ safe_fclose (&s.fpout);
a->d_filename = a->filename;
a->filename = safe_strdup (buff);
a->unlink = 1;
mutt_update_encoding (body);
body->parts = body->hdr->content;
- fclose(fp);
+ safe_fclose (&fp);
return (body);
}
if (ferror (tempfp))
{
dprint (1, (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile));
- fclose (tempfp);
+ safe_fclose (&tempfp);
unlink (tempfile);
mx_commit_message (msg, &f); /* XXX - really? */
mx_close_message (&msg);
while (!feof(index)) {
if (fgets(buf, sizeof(buf), index)) cert_num++;
}
- fclose(index);
+ safe_fclose (&index);
FOREVER
{
cur++;
}
- fclose(index);
+ safe_fclose (&index);
/* Make Helpstring */
helpstr[0] = 0;
mutt_mktemp (tmpfname);
if ((fpout = safe_fopen (tmpfname, "w+")) == NULL)
{
- fclose (fperr);
+ safe_fclose (&fperr);
mutt_perror (tmpfname);
return 1;
}
SmimeGetCertEmailCommand))== -1)
{
mutt_message (_("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ safe_fclose (&fperr);
+ safe_fclose (&fpout);
return 1;
}
}
else if(copy) ret = 2;
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
return ret;
}
mutt_mktemp (pk7out);
if ((fpout = safe_fopen (pk7out, "w+")) == NULL)
{
- fclose (fperr);
+ safe_fclose (&fperr);
mutt_perror (pk7out);
return NULL;
}
SmimePk7outCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ safe_fclose (&fperr);
+ safe_fclose (&fpout);
mutt_unlink (pk7out);
return NULL;
}
{
mutt_perror (pk7out);
mutt_copy_stream (fperr, stdout);
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
mutt_unlink (pk7out);
return NULL;
}
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_mktemp (certfile);
if ((fpout = safe_fopen (certfile, "w+")) == NULL)
{
- fclose (fperr);
+ safe_fclose (&fperr);
mutt_unlink (pk7out);
mutt_perror (certfile);
return NULL;
SmimeGetCertCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ safe_fclose (&fperr);
+ safe_fclose (&fpout);
mutt_unlink (pk7out);
mutt_unlink (certfile);
return NULL;
if (empty)
{
mutt_copy_stream (fperr, stdout);
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
mutt_unlink (certfile);
return NULL;
}
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
return safe_strdup (certfile);
}
mutt_mktemp (certfile);
if ((fpout = safe_fopen (certfile, "w+")) == NULL)
{
- fclose (fperr);
+ safe_fclose (&fperr);
mutt_perror (certfile);
return NULL;
}
SmimeGetSignerCertCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ safe_fclose (&fperr);
+ safe_fclose (&fpout);
mutt_unlink (pk7out);
mutt_unlink (certfile);
return NULL;
mutt_endwin (NULL);
mutt_copy_stream (fperr, stdout);
mutt_any_key_to_continue (NULL);
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
mutt_unlink (certfile);
return NULL;
}
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
return safe_strdup (certfile);
}
mutt_mktemp (tmpfname);
if ((fpout = safe_fopen (tmpfname, "w+")) == NULL)
{
- fclose (fperr);
+ safe_fclose (&fperr);
mutt_perror (tmpfname);
return;
}
}
fputs (buf, smimein);
fputc ('\n', smimein);
- fclose(smimein);
+ safe_fclose (&smimein);
mutt_wait_filter (thepid);
mutt_copy_stream (fpout, stdout);
mutt_copy_stream (fperr, stdout);
- fclose (fpout);
- fclose (fperr);
+ safe_fclose (&fpout);
+ safe_fclose (&fperr);
}
mutt_copy_message (fpout, Context, h, 0, 0);
fflush(fpout);
- fclose (fpout);
+ safe_fclose (&fpout);
if (h->env->from)
{
if ((smimeerr = safe_fopen (smimeerrfile, "w+")) == NULL)
{
mutt_perror (smimeerrfile);
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_unlink (tempfile);
return NULL;
}
{
mutt_perror (smimeinfile);
mutt_unlink (tempfile);
- fclose (fpout);
- fclose (smimeerr);
+ safe_fclose (&fpout);
+ safe_fclose (&smimeerr);
return NULL;
}
mutt_write_mime_header (a, fptmp);
fputc ('\n', fptmp);
mutt_write_mime_body (a, fptmp);
- fclose (fptmp);
+ safe_fclose (&fptmp);
if ((thepid =
smime_invoke_encrypt (&smimein, NULL, NULL, -1,
fileno (fpout), fileno (smimeerr),
smimeinfile, certfile)) == -1)
{
- fclose (smimeerr);
+ safe_fclose (&smimeerr);
mutt_unlink (smimeinfile);
mutt_unlink (certfile);
return (NULL);
}
- fclose (smimein);
+ safe_fclose (&smimein);
mutt_wait_filter (thepid);
mutt_unlink (smimeinfile);
fflush (fpout);
rewind (fpout);
empty = (fgetc (fpout) == EOF);
- fclose (fpout);
+ safe_fclose (&fpout);
fflush (smimeerr);
rewind (smimeerr);
err = 1;
fputs (buf, stdout);
}
- fclose (smimeerr);
+ safe_fclose (&smimeerr);
/* pause if there is any error output from SMIME */
if (err)
if ((smimeout = safe_fopen (signedfile, "w+")) == NULL)
{
mutt_perror (signedfile);
- fclose (sfp);
+ safe_fclose (&sfp);
mutt_unlink (filetosign);
return NULL;
}
mutt_write_mime_header (a, sfp);
fputc ('\n', sfp);
mutt_write_mime_body (a, sfp);
- fclose (sfp);
+ safe_fclose (&sfp);
-1, fileno (smimeout), -1, filetosign)) == -1)
{
mutt_perror _("Can't open OpenSSL subprocess!");
- fclose (smimeout);
+ safe_fclose (&smimeout);
mutt_unlink (signedfile);
mutt_unlink (filetosign);
return NULL;
}
fputs (SmimePass, smimein);
fputc ('\n', smimein);
- fclose (smimein);
+ safe_fclose (&smimein);
mutt_wait_filter (thepid);
err = 1;
fputs (buffer, stdout);
}
- fclose (smimeerr);
+ safe_fclose (&smimeerr);
fflush (smimeout);
rewind (smimeout);
empty = (fgetc (smimeout) == EOF);
- fclose (smimeout);
+ safe_fclose (&smimeout);
mutt_unlink (filetosign);
sigbdy->length = ftello (s->fpout);
sigbdy->offset = 0;
- fclose (s->fpout);
+ safe_fclose (&s->fpout);
/* restore final destination and substitute the tempfile for input */
s->fpout = fp;
tempfile, signedfile, 0)) != -1)
{
fflush (smimeout);
- fclose (smimeout);
+ safe_fclose (&smimeout);
if (mutt_wait_filter (thepid))
badsig = -1;
fflush (smimeerr);
rewind (smimeerr);
mutt_copy_stream (smimeerr, s->fpout);
- fclose (smimeerr);
+ safe_fclose (&smimeerr);
state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s);
sigbdy->offset = tmpoffset;
/* restore the original source stream */
- fclose (s->fpin);
+ safe_fclose (&s->fpin);
s->fpin = fp;
if ((smimeerr = safe_fopen (errfile, "w+")) == NULL)
{
mutt_perror (errfile);
- fclose (smimeout); smimeout = NULL;
+ safe_fclose (&smimeout); smimeout = NULL;
return NULL;
}
mutt_unlink (errfile);
if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL)
{
mutt_perror (tmpfname);
- fclose (smimeout); smimeout = NULL;
- fclose (smimeerr); smimeerr = NULL;
+ safe_fclose (&smimeout); smimeout = NULL;
+ safe_fclose (&smimeerr); smimeerr = NULL;
return NULL;
}
mutt_copy_bytes (s->fpin, tmpfp, m->length);
fflush (tmpfp);
- fclose (tmpfp);
+ safe_fclose (&tmpfp);
if ((type & ENCRYPT) &&
(thepid = smime_invoke_decrypt (&smimein, NULL, NULL, -1,
fileno (smimeout), fileno (smimeerr), tmpfname)) == -1)
{
- fclose (smimeout); smimeout = NULL;
+ safe_fclose (&smimeout); smimeout = NULL;
mutt_unlink (tmpfname);
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
fileno (smimeout), fileno (smimeerr), NULL,
tmpfname, SIGNOPAQUE)) == -1)
{
- fclose (smimeout); smimeout = NULL;
+ safe_fclose (&smimeout); smimeout = NULL;
mutt_unlink (tmpfname);
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
fputc ('\n', smimein);
}
- fclose (smimein);
+ safe_fclose (&smimein);
mutt_wait_filter (thepid);
mutt_unlink (tmpfname);
if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL)
{
mutt_perror(tmptmpfname);
- fclose (smimeout); smimeout = NULL;
+ safe_fclose (&smimeout); smimeout = NULL;
return NULL;
}
}
}
}
- fclose (smimeout);
+ safe_fclose (&smimeout);
smimeout = NULL;
mutt_unlink (outfile);
if (!outFile)
{
- fclose (fpout);
+ safe_fclose (&fpout);
mutt_unlink (tmptmpfname);
}
fpout = NULL;
m->goodsig = p->goodsig;
m->badsig = p->badsig;
}
- fclose (smimeerr);
+ safe_fclose (&smimeerr);
return (p);
}
snprintf (buf, sizeof (buf), "DATA\r\n");
if (mutt_socket_write (conn, buf) == -1)
{
- fclose (fp);
+ safe_fclose (&fp);
return smtp_err_write;
}
if ((r = smtp_get_resp (conn)))
{
- fclose (fp);
+ safe_fclose (&fp);
return r;
}
{
if (mutt_socket_write_d (conn, ".", -1, M_SOCK_LOG_FULL) == -1)
{
- fclose (fp);
+ safe_fclose (&fp);
return smtp_err_write;
}
}
if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) == -1)
{
- fclose (fp);
+ safe_fclose (&fp);
return smtp_err_write;
}
mutt_progress_update (&progress, ftell (fp), -1);
}
- fclose (fp);
+ safe_fclose (&fp);
/* terminate the message body */
if (mutt_socket_write (conn, ".\r\n") == -1)