From: Frederic Marchal Date: Sat, 4 Oct 2014 15:14:14 +0000 (+0200) Subject: Close some open files in email.c X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef4acae5b0414935fd12618c5a30ef9067f9f0d0;p=thirdparty%2Fsarg.git Close some open files in email.c This is patch #38 submitted by T.M. Abraham. Many thanks. --- diff --git a/email.c b/email.c index c3ddf30..c32608e 100644 --- a/email.c +++ b/email.c @@ -62,12 +62,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema exit(EXIT_FAILURE); } - snprintf(top1,sizeof(top1),"%s/top",dirname); - if((fp_top1=fopen(top1,"w"))==NULL) { - debuga(_("(email) Cannot open file %s: %s\n"),top1,strerror(errno)); - exit(EXIT_FAILURE); - } - snprintf(top2,sizeof(top2),"%s/top.tmp",dirname); if((fp_top2=fopen(top2,"w"))==NULL) { debuga(_("(email) Cannot open file %s: %s\n"),top2,strerror(errno)); @@ -278,6 +272,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema while(fgets(warea,sizeof(warea),fp_top3)!=NULL) fputs(warea,stdout); + if (fclose(fp_top3)==EOF) { + debuga(_("Read error in temporary mail file %s: %s\n"),top3,strerror(errno)); + exit(EXIT_FAILURE); + } } else { /* TRANSLATORS: The string is formatted using strftime. You can use any string formatting marker allowed by strftime. */