mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use safe_fclose() instead of fclose(), add fclose() to check_sec.sh

+224 -223
+4
ChangeLog
··· 1 + 2009-03-10 18:39 +0100 NONAKA Kimihiro <nonakap@gmail.com> (cc6fede605d4) 2 + 3 + * ChangeLog, mh.c: Fix crashes with 64bit time_t. Closes #3184. 4 + 1 5 2009-03-09 12:04 +0100 Vincent Lefevre <vincent@vinc17.org> (4ce562b7f5d7) 2 6 3 7 * mbyte.h: Unbreak compilation on OS X with --with-regex/--without-wc-
+2 -2
alias.c
··· 378 378 recode_buf (buf, sizeof (buf)); 379 379 write_safe_address (rc, buf); 380 380 fputc ('\n', rc); 381 - fclose (rc); 381 + safe_fclose (&rc); 382 382 mutt_message _("Alias added."); 383 383 } 384 384 else ··· 388 388 389 389 fseek_err: 390 390 mutt_perror (_("Error seeking in alias file")); 391 - fclose(rc); 391 + safe_fclose (&rc); 392 392 return; 393 393 } 394 394
+7 -7
attach.c
··· 76 76 else 77 77 mutt_perror(fpin ? tempfile : a->filename); 78 78 79 - if(fpin) fclose(fpin); 80 - if(fpout) fclose(fpout); 79 + if(fpin) safe_fclose (&fpin); 80 + if(fpout) safe_fclose (&fpout); 81 81 82 82 return a->unlink ? 0 : -1; 83 83 } ··· 176 176 goto bailout; 177 177 } 178 178 mutt_copy_stream (fp, tfp); 179 - fclose (fp); 180 - fclose (tfp); 179 + safe_fclose (&fp); 180 + safe_fclose (&tfp); 181 181 mutt_unlink (a->filename); 182 182 if (mutt_rename_file (tempfile, a->filename) != 0) 183 183 { ··· 884 884 if (stat (m->filename, &st) == -1) 885 885 { 886 886 mutt_perror ("stat"); 887 - fclose (s.fpout); 887 + safe_fclose (&s.fpout); 888 888 return (-1); 889 889 } 890 890 ··· 915 915 916 916 mutt_body_handler (m, &s); 917 917 918 - fclose (s.fpout); 918 + safe_fclose (&s.fpout); 919 919 if (fp == NULL) 920 920 { 921 921 m->length = 0; ··· 926 926 m->parts = saved_parts; 927 927 m->hdr = saved_hdr; 928 928 } 929 - fclose (s.fpin); 929 + safe_fclose (&s.fpin); 930 930 } 931 931 932 932 return (0);
+1 -1
buffy.c
··· 128 128 if ((f = fopen (path, "rb"))) 129 129 { 130 130 rc = test_last_status_new (f); 131 - fclose (f); 131 + safe_fclose (&f); 132 132 } 133 133 134 134 return rc;
+1
check_sec.sh
··· 31 31 } 32 32 33 33 do_check '\<fopen.*'\"'.*w' __FOPEN_CHECKED__ "Alert: Unchecked fopen calls." 34 + do_check '\<fclose.*'\"'.*w' __FCLOSE_CHECKED__ "Alert: Unchecked fclose calls." 34 35 do_check '\<(mutt_)?strcpy' __STRCPY_CHECKED__ "Alert: Unchecked strcpy calls." 35 36 do_check '\<strcat' __STRCAT_CHECKED__ "Alert: Unchecked strcat calls." 36 37 do_check '\<sprintf.*%s' __SPRINTF_CHECKED__ "Alert: Unchecked sprintf calls."
+1 -1
commands.c
··· 391 391 } 392 392 393 393 pipe_msg (h, fpout, decode, print); 394 - fclose (fpout); 394 + safe_fclose (&fpout); 395 395 rc = mutt_wait_filter (thepid); 396 396 } 397 397 else
+1 -1
compose.c
··· 1073 1073 FREE (&idx[idxlen]); 1074 1074 continue; 1075 1075 } 1076 - fclose (fp); 1076 + safe_fclose (&fp); 1077 1077 1078 1078 if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL) 1079 1079 {
+2 -2
copy.c
··· 633 633 fseeko (fp, cur->offset, 0); 634 634 if (mutt_copy_bytes (fp, fpout, cur->length) == -1) 635 635 { 636 - fclose (fp); 636 + safe_fclose (&fp); 637 637 mutt_free_body (&cur); 638 638 return (-1); 639 639 } 640 640 mutt_free_body (&cur); 641 - fclose (fp); 641 + safe_fclose (&fp); 642 642 } 643 643 else 644 644 {
+15 -18
crypt-gpgme.c
··· 440 440 buf[0] = c; 441 441 gpgme_data_write (data, buf, 1); 442 442 } 443 - fclose(fptmp); 443 + safe_fclose (&fptmp); 444 444 gpgme_data_seek (data, 0, SEEK_SET); 445 445 } 446 446 else 447 447 { 448 - fclose(fptmp); 448 + safe_fclose (&fptmp); 449 449 err = gpgme_data_new_from_file (&data, tempfile, 1); 450 450 } 451 451 unlink (tempfile); ··· 544 544 if (fwrite (buf, nread, 1, fp) != 1) 545 545 { 546 546 mutt_perror (tempfile); 547 - fclose (fp); 547 + safe_fclose (&fp); 548 548 unlink (tempfile); 549 549 return NULL; 550 550 } ··· 553 553 if (ret_fp) 554 554 rewind (fp); 555 555 else 556 - fclose (fp); 556 + safe_fclose (&fp); 557 557 if (nread == -1) 558 558 { 559 559 mutt_error (_("error reading data object: %s\n"), gpgme_strerror (err)); 560 560 unlink (tempfile); 561 - fclose (fp); 561 + safe_fclose (&fp); 562 562 return NULL; 563 563 } 564 564 if (ret_fp) ··· 1788 1788 b->type = saved_b_type; 1789 1789 b->length = saved_b_length; 1790 1790 b->offset = saved_b_offset; 1791 - fclose (tmpfp); 1791 + safe_fclose (&tmpfp); 1792 1792 rewind (*fpout); 1793 1793 if (*cur && !is_signed && !(*cur)->parts && mutt_is_application_smime (*cur)) 1794 1794 { ··· 1824 1824 bb->length = ftello (s.fpout); 1825 1825 bb->offset = 0; 1826 1826 rewind (tmpfp); 1827 - fclose (*fpout); 1827 + safe_fclose (fpout); 1828 1828 1829 1829 memset (&s, 0, sizeof (s)); 1830 1830 s.fpin = tmpfp; ··· 1843 1843 bb->type = saved_b_type; 1844 1844 bb->length = saved_b_length; 1845 1845 bb->offset = saved_b_offset; 1846 - fclose (tmpfp); 1846 + safe_fclose (&tmpfp); 1847 1847 rewind (*fpout); 1848 1848 mutt_free_body (cur); 1849 1849 *cur = tmp_b; ··· 1956 1956 1957 1957 err_fp: 1958 1958 if (rc) 1959 - { 1960 - fclose (*fp); 1961 - *fp = NULL; 1962 - } 1959 + safe_fclose (fp); 1963 1960 err_tmpdir: 1964 1961 if (dryrun) 1965 1962 mutt_rmtree (tmpdir); ··· 2068 2065 dprint (1, (debugfile, "error converting key file into data object\n")); 2069 2066 return; 2070 2067 } 2071 - fclose (in); 2068 + safe_fclose (&in); 2072 2069 2073 2070 if (!pgp_gpgme_extract_keys (keydata, &out, 0)) 2074 2071 { ··· 2076 2073 outlen = ftell (out); 2077 2074 fseek (out, 0, SEEK_SET); 2078 2075 mutt_copy_bytes (out, stdout, outlen); 2079 - fclose (out); 2076 + safe_fclose (&out); 2080 2077 } 2081 2078 else 2082 2079 printf (_("Error extracting key data!\n")); ··· 2150 2147 } 2151 2148 2152 2149 fgetconv_close (&fc); 2153 - fclose (fp); 2150 + safe_fclose (&fp); 2154 2151 } 2155 2152 2156 2153 ··· 2476 2473 mutt_free_body (&tattach); 2477 2474 } 2478 2475 2479 - fclose (fpout); 2476 + safe_fclose (&fpout); 2480 2477 mutt_unlink(tempfile); 2481 2478 dprint (2, (debugfile, "Leaving pgp_encrypted handler\n")); 2482 2479 ··· 2550 2547 mutt_free_body (&tattach); 2551 2548 } 2552 2549 2553 - fclose (fpout); 2550 + safe_fclose (&fpout); 2554 2551 mutt_unlink(tempfile); 2555 2552 dprint (2, (debugfile, "Leaving smime_encrypted handler\n")); 2556 2553 ··· 3506 3503 leave: 3507 3504 gpgme_key_release (k); 3508 3505 gpgme_release (listctx); 3509 - fclose (fp); 3506 + safe_fclose (&fp); 3510 3507 mutt_clear_error (); 3511 3508 snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), crypt_keyid (key)); 3512 3509 mutt_do_pager (cmd, tempfile, 0, NULL);
+3 -3
crypt.c
··· 538 538 fputc (c, fp); 539 539 540 540 } 541 - fclose (fp); 541 + safe_fclose (&fp); 542 542 543 543 return 0; 544 544 } ··· 613 613 if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT && 614 614 !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->security)) 615 615 { 616 - fclose (fpout); 616 + safe_fclose (&fpout); 617 617 break; 618 618 } 619 619 ··· 695 695 } 696 696 } 697 697 698 - fclose (fpout); 698 + safe_fclose (&fpout); 699 699 if (isendwin()) 700 700 mutt_any_key_to_continue (NULL); 701 701
+1 -1
edit.c
··· 109 109 snprintf(tmp, sizeof(tmp), "\"%s\" %lu bytes\n", path, (unsigned long) sb.st_size); 110 110 addstr(tmp); 111 111 } 112 - fclose (f); 112 + safe_fclose (&f); 113 113 } 114 114 else 115 115 {
+1 -1
editmsg.c
··· 191 191 mx_close_mailbox (&tmpctx, NULL); 192 192 193 193 bail: 194 - if (fp) fclose (fp); 194 + if (fp) safe_fclose (&fp); 195 195 196 196 if (rc >= 0) 197 197 unlink (tmp);
+1 -1
gnupgparse.c
··· 373 373 if (ferror (fp)) 374 374 mutt_perror ("fgets"); 375 375 376 - fclose (fp); 376 + safe_fclose (&fp); 377 377 mutt_wait_filter (thepid); 378 378 379 379 close (devnull);
+2 -2
handler.c
··· 1643 1643 { 1644 1644 b->length = ftello (s->fpout); 1645 1645 b->offset = 0; 1646 - fclose (s->fpout); 1646 + safe_fclose (&s->fpout); 1647 1647 1648 1648 /* restore final destination and substitute the tempfile for input */ 1649 1649 s->fpout = fp; ··· 1674 1674 b->offset = tmpoffset; 1675 1675 1676 1676 /* restore the original source stream */ 1677 - fclose (s->fpin); 1677 + safe_fclose (&s->fpin); 1678 1678 s->fpin = fp; 1679 1679 } 1680 1680 }
+5 -5
headers.c
··· 64 64 65 65 mutt_copy_stream (ifp, ofp); 66 66 67 - fclose (ifp); 68 - fclose (ofp); 67 + safe_fclose (&ifp); 68 + safe_fclose (&ofp); 69 69 70 70 if (stat (path, &st) == -1) 71 71 { ··· 98 98 if ((ofp = safe_fopen (body, "w")) == NULL) 99 99 { 100 100 /* intentionally leak a possible temporary file here */ 101 - fclose (ifp); 101 + safe_fclose (&ifp); 102 102 mutt_perror (body); 103 103 return; 104 104 } ··· 106 106 n = mutt_read_rfc822_header (ifp, NULL, 1, 0); 107 107 while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0) 108 108 fwrite (buffer, 1, i, ofp); 109 - fclose (ofp); 110 - fclose (ifp); 109 + safe_fclose (&ofp); 110 + safe_fclose (&ifp); 111 111 mutt_unlink (path); 112 112 113 113 /* restore old info. */
+1 -1
help.c
··· 367 367 if (menu != MENU_PAGER) 368 368 dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]); 369 369 370 - fclose (f); 370 + safe_fclose (&f); 371 371 372 372 snprintf (buf, sizeof (buf), _("Help for %s"), desc); 373 373 }
+5 -5
history.c
··· 90 90 } 91 91 } 92 92 93 - fclose (f); 93 + safe_fclose (&f); 94 94 FREE (&linebuf); 95 95 } 96 96 ··· 149 149 } 150 150 151 151 cleanup: 152 - fclose (f); 152 + safe_fclose (&f); 153 153 FREE (&linebuf); 154 154 if (tmp != NULL) 155 155 { ··· 158 158 { 159 159 rewind (tmp); 160 160 mutt_copy_stream (tmp, f); 161 - fclose (f); 161 + safe_fclose (&f); 162 162 } 163 - fclose (tmp); 163 + safe_fclose (&tmp); 164 164 unlink (tmpfname); 165 165 } 166 166 } ··· 196 196 } 197 197 fputs ("|\n", f); 198 198 199 - fclose (f); 199 + safe_fclose (&f); 200 200 FREE (&tmp); 201 201 202 202 if (--n < 0)
+5 -5
imap/message.c
··· 220 220 if (h.data) 221 221 imap_free_header_data ((void**) (void*) &h.data); 222 222 imap_hcache_close (idata); 223 - fclose (fp); 223 + safe_fclose (&fp); 224 224 return -1; 225 225 } 226 226 } ··· 331 331 #if USE_HCACHE 332 332 imap_hcache_close (idata); 333 333 #endif 334 - fclose (fp); 334 + safe_fclose (&fp); 335 335 return -1; 336 336 } 337 337 ··· 364 364 imap_hcache_close (idata); 365 365 #endif /* USE_HCACHE */ 366 366 367 - fclose(fp); 367 + safe_fclose (&fp); 368 368 369 369 if (ctx->msgcount > oldmsgcount) 370 370 { ··· 654 654 pc = imap_next_word (pc); 655 655 mutt_error ("%s", pc); 656 656 mutt_sleep (1); 657 - fclose (fp); 657 + safe_fclose (&fp); 658 658 goto fail; 659 659 } 660 660 ··· 677 677 flush_buffer(buf, &len, idata->conn); 678 678 679 679 mutt_socket_write (idata->conn, "\r\n"); 680 - fclose (fp); 680 + safe_fclose (&fp); 681 681 682 682 do 683 683 rc = imap_cmd_step (idata);
+2 -2
init.c
··· 254 254 /* read line */ 255 255 memset (&expn, 0, sizeof (expn)); 256 256 expn.data = mutt_read_line (NULL, &expn.dsize, fp, &line); 257 - fclose (fp); 257 + safe_fclose (&fp); 258 258 mutt_wait_filter (pid); 259 259 260 260 /* if we got output, make a new string consiting of the shell ouptput ··· 2299 2299 } 2300 2300 FREE (&token.data); 2301 2301 FREE (&linebuf); 2302 - fclose (f); 2302 + safe_fclose (&f); 2303 2303 if (pid != -1) 2304 2304 mutt_wait_filter (pid); 2305 2305 if (rc)
+3 -4
lib.c
··· 220 220 if (fflush (*f) || fsync (fileno (*f))) 221 221 { 222 222 r = -1; 223 - fclose (*f); 223 + safe_fclose (f); 224 224 } 225 225 else 226 - r = fclose(*f); 227 - *f = NULL; 226 + r = safe_fclose (f); 228 227 } 229 228 230 229 return r; ··· 345 344 fwrite (buf, 1, MIN (sizeof (buf), sb.st_size), f); 346 345 sb.st_size -= MIN (sizeof (buf), sb.st_size); 347 346 } 348 - fclose (f); 347 + safe_fclose (&f); 349 348 } 350 349 } 351 350 }
+3 -3
main.c
··· 909 909 if (!option (OPTNOCURSES)) 910 910 mutt_endwin (NULL); 911 911 perror (tempfile); 912 - fclose (fin); 912 + safe_fclose (&fin); 913 913 FREE (&tempfile); 914 914 exit (1); 915 915 } ··· 917 917 mutt_copy_stream (fin, fout); 918 918 else if (bodytext) 919 919 fputs (bodytext, fout); 920 - fclose (fout); 920 + safe_fclose (&fout); 921 921 if (fin && fin != stdin) 922 - fclose (fin); 922 + safe_fclose (&fin); 923 923 } 924 924 } 925 925
+2 -2
mbox.c
··· 877 877 if (fclose (fp) != 0) 878 878 { 879 879 fp = NULL; 880 - dprint(1, (debugfile, "mbox_sync_mailbox: fclose() returned non-zero.\n")); 880 + dprint(1, (debugfile, "mbox_sync_mailbox: safe_fclose (&) returned non-zero.\n")); 881 881 unlink (tempfile); 882 882 mutt_perror (tempfile); 883 883 mutt_sleep (5); ··· 939 939 } 940 940 } 941 941 942 - fclose (fp); 942 + safe_fclose (&fp); 943 943 fp = NULL; 944 944 mbox_unlock_mailbox (ctx); 945 945
+1 -1
mh.c
··· 637 637 h->env = mutt_read_rfc822_header (f, h, 0, 0); 638 638 639 639 fstat (fileno (f), &st); 640 - fclose (f); 640 + safe_fclose (&f); 641 641 642 642 if (!h->received) 643 643 h->received = h->date_sent;
+3 -3
mutt_ssl.c
··· 587 587 588 588 if (!X509_digest (peercert, EVP_sha1(), peermd, &peermdlen)) 589 589 { 590 - fclose (fp); 590 + safe_fclose (&fp); 591 591 return 0; 592 592 } 593 593 ··· 599 599 break; 600 600 } 601 601 X509_free (cert); 602 - fclose (fp); 602 + safe_fclose (&fp); 603 603 604 604 return pass; 605 605 } ··· 925 925 { 926 926 if (PEM_write_X509 (fp, cert)) 927 927 done = 1; 928 - fclose (fp); 928 + safe_fclose (&fp); 929 929 } 930 930 if (!done) 931 931 {
+4 -4
mutt_ssl_gnutls.c
··· 417 417 } 418 418 419 419 b64_data.size = fread(b64_data.data, 1, b64_data.size, fd1); 420 - fclose(fd1); 420 + safe_fclose (&fd1); 421 421 422 422 do { 423 423 ret = gnutls_pem_base64_decode_alloc(NULL, &b64_data, &cert); ··· 526 526 { 527 527 regfree(&preg); 528 528 FREE(&linestr); 529 - fclose(fp); 529 + safe_fclose (&fp); 530 530 return 1; 531 531 } 532 532 } ··· 534 534 } 535 535 536 536 regfree(&preg); 537 - fclose(fp); 537 + safe_fclose (&fp); 538 538 } 539 539 540 540 /* not found a matching name */ ··· 877 877 gnutls_free (pemdata.data); 878 878 } 879 879 } 880 - fclose (fp); 880 + safe_fclose (&fp); 881 881 } 882 882 if (!done) 883 883 {
+1 -1
muttlib.c
··· 1093 1093 if ((pid = mutt_create_filter(command->data, NULL, &filter, NULL))) 1094 1094 { 1095 1095 n = fread(dest, 1, destlen /* already decremented */, filter); 1096 - fclose(filter); 1096 + safe_fclose (&filter); 1097 1097 dest[n] = '\0'; 1098 1098 while (dest[n-1] == '\n' || dest[n-1] == '\r') 1099 1099 dest[--n] = '\0';
+2 -2
pager.c
··· 1542 1542 if (stat (fname, &sb) != 0) 1543 1543 { 1544 1544 mutt_perror (fname); 1545 - fclose (fp); 1545 + safe_fclose (&fp); 1546 1546 return (-1); 1547 1547 } 1548 1548 unlink (fname); ··· 2677 2677 } 2678 2678 } 2679 2679 2680 - fclose (fp); 2680 + safe_fclose (&fp); 2681 2681 if (IsHeader (extra)) 2682 2682 { 2683 2683 Context->msgnotreadyet = -1;
+2 -2
pattern.c
··· 182 182 mx_close_message (&msg); 183 183 if (s.fpout) 184 184 { 185 - fclose (s.fpout); 185 + safe_fclose (&s.fpout); 186 186 unlink (tempfile); 187 187 } 188 188 return (0); ··· 242 242 243 243 if (option (OPTTHOROUGHSRC)) 244 244 { 245 - fclose (fp); 245 + safe_fclose (&fp); 246 246 unlink (tempfile); 247 247 } 248 248 }
+34 -34
pgp.c
··· 605 605 606 606 fseeko (s->fpin, sigbdy->offset, 0); 607 607 mutt_copy_bytes (s->fpin, fp, sigbdy->length); 608 - fclose (fp); 608 + safe_fclose (&fp); 609 609 610 610 mutt_mktemp(pgperrfile); 611 611 if(!(pgperr = safe_fopen(pgperrfile, "w+"))) ··· 685 685 if (Context->hdrs[Context->v2r[i]]->security & PGPENCRYPT 686 686 && !pgp_valid_passphrase()) 687 687 { 688 - fclose (fpout); 688 + safe_fclose (&fpout); 689 689 goto bailout; 690 690 } 691 691 mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]], ··· 698 698 mutt_parse_mime_message (Context, h); 699 699 if (h->security & PGPENCRYPT && !pgp_valid_passphrase()) 700 700 { 701 - fclose (fpout); 701 + safe_fclose (&fpout); 702 702 goto bailout; 703 703 } 704 704 mutt_copy_message (fpout, Context, h, M_CM_DECODE|M_CM_CHARCONV, 0); 705 705 } 706 706 707 - fclose (fpout); 707 + safe_fclose (&fpout); 708 708 mutt_endwin (NULL); 709 709 pgp_invoke_import (tempfname); 710 710 mutt_any_key_to_continue (NULL); ··· 736 736 737 737 mutt_body_handler (top, &s); 738 738 739 - fclose (tempfp); 739 + safe_fclose (&tempfp); 740 740 741 741 pgp_invoke_import (tempfname); 742 742 mutt_any_key_to_continue (NULL); ··· 791 791 if((pgptmp = safe_fopen (pgptmpfile, "w")) == NULL) 792 792 { 793 793 mutt_perror (pgptmpfile); 794 - fclose(pgperr); 794 + safe_fclose (&pgperr); 795 795 return NULL; 796 796 } 797 797 ··· 801 801 802 802 fseeko (s->fpin, a->offset, 0); 803 803 mutt_copy_bytes (s->fpin, pgptmp, a->length); 804 - fclose (pgptmp); 804 + safe_fclose (&pgptmp); 805 805 806 806 if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1, 807 807 fileno (pgperr), pgptmpfile)) == -1) 808 808 { 809 - fclose (pgperr); 809 + safe_fclose (&pgperr); 810 810 unlink (pgptmpfile); 811 811 if (s->flags & M_DISPLAY) 812 812 state_attach_puts (_("[-- Error: could not create a PGP subprocess! --]\n\n"), s); ··· 819 819 if (!pgp_use_gpg_agent()) 820 820 fputs (PgpPass, pgpin); 821 821 fputc ('\n', pgpin); 822 - fclose(pgpin); 822 + safe_fclose (&pgpin); 823 823 824 824 /* Read the output from PGP, and make sure to change CRLF to LF, otherwise 825 825 * read_mime_header has a hard time parsing the message. ··· 832 832 fputs (buf, fpout); 833 833 } 834 834 835 - fclose (pgpout); 835 + safe_fclose (&pgpout); 836 836 rv = mutt_wait_filter (thepid); 837 837 mutt_unlink(pgptmpfile); 838 838 ··· 846 846 p->goodsig = 0; 847 847 state_attach_puts (_("[-- End of PGP output --]\n\n"), s); 848 848 } 849 - fclose (pgperr); 849 + safe_fclose (&pgperr); 850 850 851 851 fflush (fpout); 852 852 rewind (fpout); ··· 985 985 rc = -1; 986 986 } 987 987 988 - fclose (fpout); 988 + safe_fclose (&fpout); 989 989 mutt_unlink(tempfile); 990 990 991 991 return rc; ··· 1018 1018 if ((sfp = safe_fopen(signedfile, "w")) == NULL) 1019 1019 { 1020 1020 mutt_perror(signedfile); 1021 - fclose(fp); 1021 + safe_fclose (&fp); 1022 1022 unlink(sigfile); 1023 1023 return NULL; 1024 1024 } ··· 1026 1026 mutt_write_mime_header (a, sfp); 1027 1027 fputc ('\n', sfp); 1028 1028 mutt_write_mime_body (a, sfp); 1029 - fclose(sfp); 1029 + safe_fclose (&sfp); 1030 1030 1031 1031 if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr, 1032 1032 -1, -1, -1, signedfile)) == -1) 1033 1033 { 1034 1034 mutt_perror _("Can't open PGP subprocess!"); 1035 - fclose(fp); 1035 + safe_fclose (&fp); 1036 1036 unlink(sigfile); 1037 1037 unlink(signedfile); 1038 1038 return NULL; ··· 1041 1041 if (!pgp_use_gpg_agent()) 1042 1042 fputs(PgpPass, pgpin); 1043 1043 fputc('\n', pgpin); 1044 - fclose(pgpin); 1044 + safe_fclose (&pgpin); 1045 1045 1046 1046 /* 1047 1047 * Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as ··· 1069 1069 if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT)) 1070 1070 empty=1; 1071 1071 1072 - fclose (pgperr); 1073 - fclose (pgpout); 1072 + safe_fclose (&pgperr); 1073 + safe_fclose (&pgpout); 1074 1074 unlink (signedfile); 1075 1075 1076 1076 if (fclose (fp) != 0) ··· 1268 1268 { 1269 1269 mutt_perror (pgperrfile); 1270 1270 unlink(tempfile); 1271 - fclose(fpout); 1271 + safe_fclose (&fpout); 1272 1272 return NULL; 1273 1273 } 1274 1274 unlink (pgperrfile); ··· 1278 1278 { 1279 1279 mutt_perror(pgpinfile); 1280 1280 unlink(tempfile); 1281 - fclose(fpout); 1282 - fclose(pgperr); 1281 + safe_fclose (&fpout); 1282 + safe_fclose (&pgperr); 1283 1283 return NULL; 1284 1284 } 1285 1285 ··· 1289 1289 mutt_write_mime_header (a, fptmp); 1290 1290 fputc ('\n', fptmp); 1291 1291 mutt_write_mime_body (a, fptmp); 1292 - fclose(fptmp); 1292 + safe_fclose (&fptmp); 1293 1293 1294 1294 if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1, 1295 1295 fileno (fpout), fileno (pgperr), 1296 1296 pgpinfile, keylist, sign)) == -1) 1297 1297 { 1298 - fclose (pgperr); 1298 + safe_fclose (&pgperr); 1299 1299 unlink(pgpinfile); 1300 1300 return (NULL); 1301 1301 } ··· 1306 1306 fputs (PgpPass, pgpin); 1307 1307 fputc ('\n', pgpin); 1308 1308 } 1309 - fclose(pgpin); 1309 + safe_fclose (&pgpin); 1310 1310 1311 1311 if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT)) 1312 1312 empty=1; ··· 1317 1317 rewind (fpout); 1318 1318 if(!empty) 1319 1319 empty = (fgetc (fpout) == EOF); 1320 - fclose (fpout); 1320 + safe_fclose (&fpout); 1321 1321 1322 1322 fflush (pgperr); 1323 1323 rewind (pgperr); ··· 1326 1326 err = 1; 1327 1327 fputs (buf, stdout); 1328 1328 } 1329 - fclose (pgperr); 1329 + safe_fclose (&pgperr); 1330 1330 1331 1331 /* pause if there is any error output from PGP */ 1332 1332 if (err) ··· 1406 1406 if ((pgpin = safe_fopen (pgpinfile, "w")) == NULL) 1407 1407 { 1408 1408 mutt_perror (pgpinfile); 1409 - fclose (fp); 1409 + safe_fclose (&fp); 1410 1410 return NULL; 1411 1411 } 1412 1412 ··· 1445 1445 mutt_copy_stream (fp, pgpin); 1446 1446 } 1447 1447 safe_fclose (&fp); 1448 - fclose (pgpin); 1448 + safe_fclose (&pgpin); 1449 1449 1450 1450 mutt_mktemp (pgpoutfile); 1451 1451 mutt_mktemp (pgperrfile); ··· 1456 1456 unlink (pgpinfile); 1457 1457 if (pgpout) 1458 1458 { 1459 - fclose (pgpout); 1459 + safe_fclose (&pgpout); 1460 1460 unlink (pgpoutfile); 1461 1461 } 1462 1462 return NULL; ··· 1469 1469 pgpinfile, keylist, flags)) == -1) 1470 1470 { 1471 1471 mutt_perror _("Can't invoke PGP"); 1472 - fclose (pgpout); 1473 - fclose (pgperr); 1472 + safe_fclose (&pgpout); 1473 + safe_fclose (&pgperr); 1474 1474 mutt_unlink (pgpinfile); 1475 1475 unlink (pgpoutfile); 1476 1476 return NULL; ··· 1480 1480 *PgpPass = 0; 1481 1481 if (flags & SIGN) 1482 1482 fprintf (pgpin, "%s\n", PgpPass); 1483 - fclose (pgpin); 1483 + safe_fclose (&pgpin); 1484 1484 1485 1485 if(mutt_wait_filter (thepid) && option(OPTPGPCHECKEXIT)) 1486 1486 empty=1; ··· 1495 1495 1496 1496 if(!empty) 1497 1497 empty = (fgetc (pgpout) == EOF); 1498 - fclose (pgpout); 1498 + safe_fclose (&pgpout); 1499 1499 1500 1500 err = 0; 1501 1501 ··· 1505 1505 fputs (buff, stdout); 1506 1506 } 1507 1507 1508 - fclose (pgperr); 1508 + safe_fclose (&pgperr); 1509 1509 1510 1510 if (err) 1511 1511 mutt_any_key_to_continue (NULL);
+10 -10
pgpkey.c
··· 555 555 } 556 556 if ((fp = safe_fopen (tempfile, "w")) == NULL) 557 557 { 558 - fclose (devnull); 558 + safe_fclose (&devnull); 559 559 mutt_perror _("Can't create temporary file"); 560 560 break; 561 561 } ··· 569 569 { 570 570 mutt_perror _("Can't create filter"); 571 571 unlink (tempfile); 572 - fclose (fp); 573 - fclose (devnull); 572 + safe_fclose (&fp); 573 + safe_fclose (&devnull); 574 574 } 575 575 576 576 mutt_wait_filter (thepid); 577 - fclose (fp); 578 - fclose (devnull); 577 + safe_fclose (&fp); 578 + safe_fclose (&devnull); 579 579 mutt_clear_error (); 580 580 snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), 581 581 pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent))); ··· 743 743 if ((devnull = fopen ("/dev/null", "w")) == NULL) /* __FOPEN_CHECKED__ */ 744 744 { 745 745 mutt_perror _("Can't open /dev/null"); 746 - fclose (tempfp); 746 + safe_fclose (&tempfp); 747 747 if (tempf == tempfb) 748 748 unlink (tempf); 749 749 return NULL; ··· 758 758 { 759 759 mutt_perror _("Can't create filter"); 760 760 unlink (tempf); 761 - fclose (tempfp); 762 - fclose (devnull); 761 + safe_fclose (&tempfp); 762 + safe_fclose (&devnull); 763 763 return NULL; 764 764 } 765 765 766 766 mutt_wait_filter (thepid); 767 767 768 - fclose (tempfp); 769 - fclose (devnull); 768 + safe_fclose (&tempfp); 769 + safe_fclose (&devnull); 770 770 771 771 att = mutt_new_body (); 772 772 att->filename = safe_strdup (tempf);
+1 -1
pgppubring.c
··· 815 815 FGETPOS(rfp,pos); 816 816 } 817 817 818 - fclose (rfp); 818 + safe_fclose (&rfp); 819 819 820 820 } 821 821
+1 -1
pop.c
··· 130 130 } 131 131 } 132 132 133 - fclose (f); 133 + safe_fclose (&f); 134 134 unlink (tempfile); 135 135 return ret; 136 136 }
+1 -1
postpone.c
··· 705 705 bail: 706 706 707 707 /* that's it. */ 708 - if (bfp != fp) fclose (bfp); 708 + if (bfp != fp) safe_fclose (&bfp); 709 709 if (msg) mx_close_message (&msg); 710 710 711 711 if (rv == -1)
+1 -1
query.c
··· 123 123 } 124 124 } 125 125 FREE (&buf); 126 - fclose (fp); 126 + safe_fclose (&fp); 127 127 if (mutt_wait_filter (thepid)) 128 128 { 129 129 dprint (1, (debugfile, "Error: %s\n", msg));
+7 -7
recvattach.c
··· 518 518 if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL) 519 519 { 520 520 fprintf(fpout, "%s", AttachSep); 521 - fclose (fpout); 521 + safe_fclose (&fpout); 522 522 } 523 523 } 524 524 else ··· 527 527 if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL) 528 528 { 529 529 fprintf(fpout, "%s", AttachSep); 530 - fclose (fpout); 530 + safe_fclose (&fpout); 531 531 } 532 532 } 533 533 } ··· 622 622 return; 623 623 } 624 624 mutt_copy_stream (ifp, state->fpout); 625 - fclose (ifp); 625 + safe_fclose (&ifp); 626 626 if (AttachSep) 627 627 state_puts (AttachSep, state); 628 628 } ··· 671 671 mutt_endwin (NULL); 672 672 thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL); 673 673 pipe_attachment_list (buf, fp, tag, top, filter, &state); 674 - fclose (state.fpout); 674 + safe_fclose (&state.fpout); 675 675 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) 676 676 mutt_any_key_to_continue (NULL); 677 677 } ··· 737 737 if ((ifp = fopen (newfile, "r")) != NULL) 738 738 { 739 739 mutt_copy_stream (ifp, state->fpout); 740 - fclose (ifp); 740 + safe_fclose (&ifp); 741 741 if (AttachSep) 742 742 state_puts (AttachSep, state); 743 743 } ··· 771 771 memset (&state, 0, sizeof (STATE)); 772 772 thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL); 773 773 print_attachment_list (fp, tag, top, &state); 774 - fclose (state.fpout); 774 + safe_fclose (&state.fpout); 775 775 if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) 776 776 mutt_any_key_to_continue (NULL); 777 777 } ··· 1242 1242 1243 1243 if (WithCrypto && need_secured && secured) 1244 1244 { 1245 - fclose (fp); 1245 + safe_fclose (&fp); 1246 1246 mutt_free_body (&cur); 1247 1247 } 1248 1248
+5 -5
recvcmd.c
··· 515 515 516 516 mutt_forward_trailer (tmpfp); 517 517 518 - fclose (tmpfp); 518 + safe_fclose (&tmpfp); 519 519 tmpfp = NULL; 520 520 521 521 /* now that we have the template, send it. */ ··· 526 526 527 527 if (tmpfp) 528 528 { 529 - fclose (tmpfp); 529 + safe_fclose (&tmpfp); 530 530 mutt_unlink (tmpbody); 531 531 } 532 532 ··· 631 631 } 632 632 } 633 633 } 634 - fclose (tmpfp); 634 + safe_fclose (&tmpfp); 635 635 } 636 636 else if (rc == M_YES) /* do MIME encapsulation - we don't need to do much here */ 637 637 { ··· 907 907 copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen, 0) == NULL) 908 908 { 909 909 mutt_free_header (&tmphdr); 910 - fclose (tmpfp); 910 + safe_fclose (&tmpfp); 911 911 return; 912 912 } 913 913 } 914 914 915 - fclose (tmpfp); 915 + safe_fclose (&tmpfp); 916 916 917 917 if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent) == 0) 918 918 mutt_set_flag (Context, hdr, M_REPLIED, 1);
+4 -4
rfc1524.c
··· 346 346 } 347 347 } 348 348 } /* while (!found && (buf = mutt_read_line ())) */ 349 - fclose (fp); 349 + safe_fclose (&fp); 350 350 } /* if ((fp = fopen ())) */ 351 351 FREE (&buf); 352 352 return found; ··· 581 581 return 3; 582 582 if ((nfp = safe_fopen (newfile,"w")) == NULL) 583 583 { 584 - fclose(ofp); 584 + safe_fclose (&ofp); 585 585 return 3; 586 586 } 587 587 mutt_copy_stream (ofp,nfp); 588 - fclose (nfp); 589 - fclose (ofp); 588 + safe_fclose (&nfp); 589 + safe_fclose (&ofp); 590 590 mutt_unlink (oldfile); 591 591 return 0; 592 592 }
+3 -3
rfc3676.c
··· 270 270 mutt_mktemp (tmpfile); 271 271 if ((out = safe_fopen (tmpfile, "w+")) == NULL) 272 272 { 273 - fclose (in); 273 + safe_fclose (&in); 274 274 return; 275 275 } 276 276 ··· 294 294 } 295 295 fputs (buf, out); 296 296 } 297 - fclose (in); 298 - fclose (out); 297 + safe_fclose (&in); 298 + safe_fclose (&out); 299 299 mutt_set_mtime (hdr->content->filename, tmpfile); 300 300 unlink (hdr->content->filename); 301 301 mutt_str_replace (&hdr->content->filename, tmpfile);
+2 -2
send.c
··· 59 59 if (option (OPTSIGDASHES)) 60 60 fputs ("\n-- \n", f); 61 61 mutt_copy_stream (tmpfp, f); 62 - fclose (tmpfp); 62 + safe_fclose (&tmpfp); 63 63 if (thepid != -1) 64 64 mutt_wait_filter (thepid); 65 65 } ··· 997 997 998 998 if ((mutt_write_mime_body (msg->content, tempfp) == -1)) 999 999 { 1000 - fclose(tempfp); 1000 + safe_fclose (&tempfp); 1001 1001 unlink (tempfile); 1002 1002 return (-1); 1003 1003 }
+8 -8
sendlib.c
··· 458 458 mutt_copy_stream (fpin, f); 459 459 460 460 fgetconv_close (&fc); 461 - fclose (fpin); 461 + safe_fclose (&fpin); 462 462 463 463 return (ferror (f) ? -1 : 0); 464 464 } ··· 1004 1004 p = NULL; 1005 1005 } 1006 1006 } 1007 - fclose (f); 1007 + safe_fclose (&f); 1008 1008 } 1009 1009 } 1010 1010 ··· 1041 1041 if (stat (a->filename, &sb) == -1) 1042 1042 { 1043 1043 mutt_perror ("stat"); 1044 - fclose (fpin); 1044 + safe_fclose (&fpin); 1045 1045 } 1046 1046 a->length = sb.st_size; 1047 1047 } ··· 1070 1070 FREE (&line); 1071 1071 1072 1072 if (fpin && !fp) 1073 - fclose (fpin); 1073 + safe_fclose (&fpin); 1074 1074 if (fpout) 1075 - fclose (fpout); 1075 + safe_fclose (&fpout); 1076 1076 else 1077 1077 return; 1078 1078 ··· 1125 1125 } 1126 1126 s.fpin = fpin; 1127 1127 mutt_decode_attachment (a, &s); 1128 - fclose (s.fpout); 1128 + safe_fclose (&s.fpout); 1129 1129 a->d_filename = a->filename; 1130 1130 a->filename = safe_strdup (buff); 1131 1131 a->unlink = 1; ··· 1328 1328 mutt_update_encoding (body); 1329 1329 body->parts = body->hdr->content; 1330 1330 1331 - fclose(fp); 1331 + safe_fclose (&fp); 1332 1332 1333 1333 return (body); 1334 1334 } ··· 2604 2604 if (ferror (tempfp)) 2605 2605 { 2606 2606 dprint (1, (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile)); 2607 - fclose (tempfp); 2607 + safe_fclose (&tempfp); 2608 2608 unlink (tempfile); 2609 2609 mx_commit_message (msg, &f); /* XXX - really? */ 2610 2610 mx_close_message (&msg);
+61 -61
smime.c
··· 381 381 while (!feof(index)) { 382 382 if (fgets(buf, sizeof(buf), index)) cert_num++; 383 383 } 384 - fclose(index); 384 + safe_fclose (&index); 385 385 386 386 FOREVER 387 387 { ··· 425 425 426 426 cur++; 427 427 } 428 - fclose(index); 428 + safe_fclose (&index); 429 429 430 430 /* Make Helpstring */ 431 431 helpstr[0] = 0; ··· 836 836 mutt_mktemp (tmpfname); 837 837 if ((fpout = safe_fopen (tmpfname, "w+")) == NULL) 838 838 { 839 - fclose (fperr); 839 + safe_fclose (&fperr); 840 840 mutt_perror (tmpfname); 841 841 return 1; 842 842 } ··· 848 848 SmimeGetCertEmailCommand))== -1) 849 849 { 850 850 mutt_message (_("Error: unable to create OpenSSL subprocess!")); 851 - fclose (fperr); 852 - fclose (fpout); 851 + safe_fclose (&fperr); 852 + safe_fclose (&fpout); 853 853 return 1; 854 854 } 855 855 ··· 899 899 } 900 900 else if(copy) ret = 2; 901 901 902 - fclose (fpout); 903 - fclose (fperr); 902 + safe_fclose (&fpout); 903 + safe_fclose (&fperr); 904 904 905 905 return ret; 906 906 } ··· 927 927 mutt_mktemp (pk7out); 928 928 if ((fpout = safe_fopen (pk7out, "w+")) == NULL) 929 929 { 930 - fclose (fperr); 930 + safe_fclose (&fperr); 931 931 mutt_perror (pk7out); 932 932 return NULL; 933 933 } ··· 941 941 SmimePk7outCommand))== -1) 942 942 { 943 943 mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!")); 944 - fclose (fperr); 945 - fclose (fpout); 944 + safe_fclose (&fperr); 945 + safe_fclose (&fpout); 946 946 mutt_unlink (pk7out); 947 947 return NULL; 948 948 } ··· 959 959 { 960 960 mutt_perror (pk7out); 961 961 mutt_copy_stream (fperr, stdout); 962 - fclose (fpout); 963 - fclose (fperr); 962 + safe_fclose (&fpout); 963 + safe_fclose (&fperr); 964 964 mutt_unlink (pk7out); 965 965 return NULL; 966 966 967 967 } 968 968 969 969 970 - fclose (fpout); 970 + safe_fclose (&fpout); 971 971 mutt_mktemp (certfile); 972 972 if ((fpout = safe_fopen (certfile, "w+")) == NULL) 973 973 { 974 - fclose (fperr); 974 + safe_fclose (&fperr); 975 975 mutt_unlink (pk7out); 976 976 mutt_perror (certfile); 977 977 return NULL; ··· 985 985 SmimeGetCertCommand))== -1) 986 986 { 987 987 mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!")); 988 - fclose (fperr); 989 - fclose (fpout); 988 + safe_fclose (&fperr); 989 + safe_fclose (&fpout); 990 990 mutt_unlink (pk7out); 991 991 mutt_unlink (certfile); 992 992 return NULL; ··· 1004 1004 if (empty) 1005 1005 { 1006 1006 mutt_copy_stream (fperr, stdout); 1007 - fclose (fpout); 1008 - fclose (fperr); 1007 + safe_fclose (&fpout); 1008 + safe_fclose (&fperr); 1009 1009 mutt_unlink (certfile); 1010 1010 return NULL; 1011 1011 } 1012 1012 1013 - fclose (fpout); 1014 - fclose (fperr); 1013 + safe_fclose (&fpout); 1014 + safe_fclose (&fperr); 1015 1015 1016 1016 return safe_strdup (certfile); 1017 1017 } ··· 1037 1037 mutt_mktemp (certfile); 1038 1038 if ((fpout = safe_fopen (certfile, "w+")) == NULL) 1039 1039 { 1040 - fclose (fperr); 1040 + safe_fclose (&fperr); 1041 1041 mutt_perror (certfile); 1042 1042 return NULL; 1043 1043 } ··· 1050 1050 SmimeGetSignerCertCommand))== -1) 1051 1051 { 1052 1052 mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!")); 1053 - fclose (fperr); 1054 - fclose (fpout); 1053 + safe_fclose (&fperr); 1054 + safe_fclose (&fpout); 1055 1055 mutt_unlink (pk7out); 1056 1056 mutt_unlink (certfile); 1057 1057 return NULL; ··· 1069 1069 mutt_endwin (NULL); 1070 1070 mutt_copy_stream (fperr, stdout); 1071 1071 mutt_any_key_to_continue (NULL); 1072 - fclose (fpout); 1073 - fclose (fperr); 1072 + safe_fclose (&fpout); 1073 + safe_fclose (&fperr); 1074 1074 mutt_unlink (certfile); 1075 1075 return NULL; 1076 1076 } 1077 1077 1078 - fclose (fpout); 1079 - fclose (fperr); 1078 + safe_fclose (&fpout); 1079 + safe_fclose (&fperr); 1080 1080 1081 1081 return safe_strdup (certfile); 1082 1082 } ··· 1103 1103 mutt_mktemp (tmpfname); 1104 1104 if ((fpout = safe_fopen (tmpfname, "w+")) == NULL) 1105 1105 { 1106 - fclose (fperr); 1106 + safe_fclose (&fperr); 1107 1107 mutt_perror (tmpfname); 1108 1108 return; 1109 1109 } ··· 1129 1129 } 1130 1130 fputs (buf, smimein); 1131 1131 fputc ('\n', smimein); 1132 - fclose(smimein); 1132 + safe_fclose (&smimein); 1133 1133 1134 1134 mutt_wait_filter (thepid); 1135 1135 ··· 1145 1145 mutt_copy_stream (fpout, stdout); 1146 1146 mutt_copy_stream (fperr, stdout); 1147 1147 1148 - fclose (fpout); 1149 - fclose (fperr); 1148 + safe_fclose (&fpout); 1149 + safe_fclose (&fperr); 1150 1150 1151 1151 } 1152 1152 ··· 1173 1173 mutt_copy_message (fpout, Context, h, 0, 0); 1174 1174 1175 1175 fflush(fpout); 1176 - fclose (fpout); 1176 + safe_fclose (&fpout); 1177 1177 1178 1178 if (h->env->from) 1179 1179 { ··· 1274 1274 if ((smimeerr = safe_fopen (smimeerrfile, "w+")) == NULL) 1275 1275 { 1276 1276 mutt_perror (smimeerrfile); 1277 - fclose (fpout); 1277 + safe_fclose (&fpout); 1278 1278 mutt_unlink (tempfile); 1279 1279 return NULL; 1280 1280 } ··· 1285 1285 { 1286 1286 mutt_perror (smimeinfile); 1287 1287 mutt_unlink (tempfile); 1288 - fclose (fpout); 1289 - fclose (smimeerr); 1288 + safe_fclose (&fpout); 1289 + safe_fclose (&smimeerr); 1290 1290 return NULL; 1291 1291 } 1292 1292 ··· 1308 1308 mutt_write_mime_header (a, fptmp); 1309 1309 fputc ('\n', fptmp); 1310 1310 mutt_write_mime_body (a, fptmp); 1311 - fclose (fptmp); 1311 + safe_fclose (&fptmp); 1312 1312 1313 1313 if ((thepid = 1314 1314 smime_invoke_encrypt (&smimein, NULL, NULL, -1, 1315 1315 fileno (fpout), fileno (smimeerr), 1316 1316 smimeinfile, certfile)) == -1) 1317 1317 { 1318 - fclose (smimeerr); 1318 + safe_fclose (&smimeerr); 1319 1319 mutt_unlink (smimeinfile); 1320 1320 mutt_unlink (certfile); 1321 1321 return (NULL); 1322 1322 } 1323 1323 1324 - fclose (smimein); 1324 + safe_fclose (&smimein); 1325 1325 1326 1326 mutt_wait_filter (thepid); 1327 1327 mutt_unlink (smimeinfile); ··· 1330 1330 fflush (fpout); 1331 1331 rewind (fpout); 1332 1332 empty = (fgetc (fpout) == EOF); 1333 - fclose (fpout); 1333 + safe_fclose (&fpout); 1334 1334 1335 1335 fflush (smimeerr); 1336 1336 rewind (smimeerr); ··· 1339 1339 err = 1; 1340 1340 fputs (buf, stdout); 1341 1341 } 1342 - fclose (smimeerr); 1342 + safe_fclose (&smimeerr); 1343 1343 1344 1344 /* pause if there is any error output from SMIME */ 1345 1345 if (err) ··· 1409 1409 if ((smimeout = safe_fopen (signedfile, "w+")) == NULL) 1410 1410 { 1411 1411 mutt_perror (signedfile); 1412 - fclose (sfp); 1412 + safe_fclose (&sfp); 1413 1413 mutt_unlink (filetosign); 1414 1414 return NULL; 1415 1415 } ··· 1417 1417 mutt_write_mime_header (a, sfp); 1418 1418 fputc ('\n', sfp); 1419 1419 mutt_write_mime_body (a, sfp); 1420 - fclose (sfp); 1420 + safe_fclose (&sfp); 1421 1421 1422 1422 1423 1423 ··· 1436 1436 -1, fileno (smimeout), -1, filetosign)) == -1) 1437 1437 { 1438 1438 mutt_perror _("Can't open OpenSSL subprocess!"); 1439 - fclose (smimeout); 1439 + safe_fclose (&smimeout); 1440 1440 mutt_unlink (signedfile); 1441 1441 mutt_unlink (filetosign); 1442 1442 return NULL; 1443 1443 } 1444 1444 fputs (SmimePass, smimein); 1445 1445 fputc ('\n', smimein); 1446 - fclose (smimein); 1446 + safe_fclose (&smimein); 1447 1447 1448 1448 1449 1449 mutt_wait_filter (thepid); ··· 1457 1457 err = 1; 1458 1458 fputs (buffer, stdout); 1459 1459 } 1460 - fclose (smimeerr); 1460 + safe_fclose (&smimeerr); 1461 1461 1462 1462 1463 1463 fflush (smimeout); 1464 1464 rewind (smimeout); 1465 1465 empty = (fgetc (smimeout) == EOF); 1466 - fclose (smimeout); 1466 + safe_fclose (&smimeout); 1467 1467 1468 1468 mutt_unlink (filetosign); 1469 1469 ··· 1584 1584 1585 1585 sigbdy->length = ftello (s->fpout); 1586 1586 sigbdy->offset = 0; 1587 - fclose (s->fpout); 1587 + safe_fclose (&s->fpout); 1588 1588 1589 1589 /* restore final destination and substitute the tempfile for input */ 1590 1590 s->fpout = fp; ··· 1612 1612 tempfile, signedfile, 0)) != -1) 1613 1613 { 1614 1614 fflush (smimeout); 1615 - fclose (smimeout); 1615 + safe_fclose (&smimeout); 1616 1616 1617 1617 if (mutt_wait_filter (thepid)) 1618 1618 badsig = -1; ··· 1636 1636 fflush (smimeerr); 1637 1637 rewind (smimeerr); 1638 1638 mutt_copy_stream (smimeerr, s->fpout); 1639 - fclose (smimeerr); 1639 + safe_fclose (&smimeerr); 1640 1640 1641 1641 state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s); 1642 1642 ··· 1647 1647 sigbdy->offset = tmpoffset; 1648 1648 1649 1649 /* restore the original source stream */ 1650 - fclose (s->fpin); 1650 + safe_fclose (&s->fpin); 1651 1651 s->fpin = fp; 1652 1652 1653 1653 ··· 1692 1692 if ((smimeerr = safe_fopen (errfile, "w+")) == NULL) 1693 1693 { 1694 1694 mutt_perror (errfile); 1695 - fclose (smimeout); smimeout = NULL; 1695 + safe_fclose (&smimeout); smimeout = NULL; 1696 1696 return NULL; 1697 1697 } 1698 1698 mutt_unlink (errfile); ··· 1702 1702 if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL) 1703 1703 { 1704 1704 mutt_perror (tmpfname); 1705 - fclose (smimeout); smimeout = NULL; 1706 - fclose (smimeerr); smimeerr = NULL; 1705 + safe_fclose (&smimeout); smimeout = NULL; 1706 + safe_fclose (&smimeerr); smimeerr = NULL; 1707 1707 return NULL; 1708 1708 } 1709 1709 ··· 1713 1713 mutt_copy_bytes (s->fpin, tmpfp, m->length); 1714 1714 1715 1715 fflush (tmpfp); 1716 - fclose (tmpfp); 1716 + safe_fclose (&tmpfp); 1717 1717 1718 1718 if ((type & ENCRYPT) && 1719 1719 (thepid = smime_invoke_decrypt (&smimein, NULL, NULL, -1, 1720 1720 fileno (smimeout), fileno (smimeerr), tmpfname)) == -1) 1721 1721 { 1722 - fclose (smimeout); smimeout = NULL; 1722 + safe_fclose (&smimeout); smimeout = NULL; 1723 1723 mutt_unlink (tmpfname); 1724 1724 if (s->flags & M_DISPLAY) 1725 1725 state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s); ··· 1730 1730 fileno (smimeout), fileno (smimeerr), NULL, 1731 1731 tmpfname, SIGNOPAQUE)) == -1) 1732 1732 { 1733 - fclose (smimeout); smimeout = NULL; 1733 + safe_fclose (&smimeout); smimeout = NULL; 1734 1734 mutt_unlink (tmpfname); 1735 1735 if (s->flags & M_DISPLAY) 1736 1736 state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s); ··· 1746 1746 fputc ('\n', smimein); 1747 1747 } 1748 1748 1749 - fclose (smimein); 1749 + safe_fclose (&smimein); 1750 1750 1751 1751 mutt_wait_filter (thepid); 1752 1752 mutt_unlink (tmpfname); ··· 1785 1785 if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL) 1786 1786 { 1787 1787 mutt_perror(tmptmpfname); 1788 - fclose (smimeout); smimeout = NULL; 1788 + safe_fclose (&smimeout); smimeout = NULL; 1789 1789 return NULL; 1790 1790 } 1791 1791 } ··· 1819 1819 } 1820 1820 1821 1821 } 1822 - fclose (smimeout); 1822 + safe_fclose (&smimeout); 1823 1823 smimeout = NULL; 1824 1824 mutt_unlink (outfile); 1825 1825 1826 1826 if (!outFile) 1827 1827 { 1828 - fclose (fpout); 1828 + safe_fclose (&fpout); 1829 1829 mutt_unlink (tmptmpfname); 1830 1830 } 1831 1831 fpout = NULL; ··· 1857 1857 m->goodsig = p->goodsig; 1858 1858 m->badsig = p->badsig; 1859 1859 } 1860 - fclose (smimeerr); 1860 + safe_fclose (&smimeerr); 1861 1861 1862 1862 return (p); 1863 1863 }
+5 -5
smtp.c
··· 164 164 snprintf (buf, sizeof (buf), "DATA\r\n"); 165 165 if (mutt_socket_write (conn, buf) == -1) 166 166 { 167 - fclose (fp); 167 + safe_fclose (&fp); 168 168 return smtp_err_write; 169 169 } 170 170 if ((r = smtp_get_resp (conn))) 171 171 { 172 - fclose (fp); 172 + safe_fclose (&fp); 173 173 return r; 174 174 } 175 175 ··· 183 183 { 184 184 if (mutt_socket_write_d (conn, ".", -1, M_SOCK_LOG_FULL) == -1) 185 185 { 186 - fclose (fp); 186 + safe_fclose (&fp); 187 187 return smtp_err_write; 188 188 } 189 189 } 190 190 if (mutt_socket_write_d (conn, buf, -1, M_SOCK_LOG_FULL) == -1) 191 191 { 192 - fclose (fp); 192 + safe_fclose (&fp); 193 193 return smtp_err_write; 194 194 } 195 195 196 196 mutt_progress_update (&progress, ftell (fp), -1); 197 197 } 198 - fclose (fp); 198 + safe_fclose (&fp); 199 199 200 200 /* terminate the message body */ 201 201 if (mutt_socket_write (conn, ".\r\n") == -1)