From 204781f47bcc0ab8682926689607affa437de4ac Mon Sep 17 00:00:00 2001 From: Frederic Marchal Date: Sat, 25 Apr 2015 21:29:28 +0200 Subject: [PATCH] Output only two sets of messages when fclose fails One message is for write errors and the other is for read errors. Read errors were mostly not detected before this change. --- auth.c | 5 ++++- authfail.c | 5 ++++- convlog.c | 2 +- dansguardian_log.c | 10 ++++++++-- dansguardian_report.c | 5 ++++- datafile.c | 5 ++++- denied.c | 5 ++++- download.c | 5 ++++- email.c | 12 +++++++++--- exclude.c | 10 ++++++++-- getconf.c | 5 ++++- grepday.c | 9 +++++++-- html.c | 22 +++++++++++++++++----- index.c | 6 ++++-- log.c | 5 ++++- readlog.c | 4 ++-- realtime.c | 5 ++++- redirector.c | 15 ++++++++++++--- repday.c | 5 ++++- report.c | 7 +++++-- siteuser.c | 5 ++++- splitlog.c | 3 ++- topsites.c | 10 ++++++++-- topuser.c | 10 ++++++++-- url.c | 5 ++++- useragent.c | 20 ++++++++++++++++---- userinfo.c | 5 ++++- usertab.c | 5 ++++- util.c | 31 +++++++++++++++++++++++-------- 29 files changed, 186 insertions(+), 55 deletions(-) diff --git a/auth.c b/auth.c index bf54d61..ed043b5 100644 --- a/auth.c +++ b/auth.c @@ -66,7 +66,10 @@ void htaccess(const struct userinfostruct *uinfo) debuga(_("Write error in \"%s\": %s\n"),htname,strerror(errno)); exit(EXIT_FAILURE); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno)); + exit(EXIT_FAILURE); + } return; } diff --git a/authfail.c b/authfail.c index 1214d09..467fd42 100644 --- a/authfail.c +++ b/authfail.c @@ -264,7 +264,10 @@ void authfail_report(void) output_html_link(fp_ou,url,100); fputs("\n",fp_ou); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),authfail_sort,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if(count>AuthfailReportLimit && AuthfailReportLimit>0) diff --git a/convlog.c b/convlog.c index 9c60515..170b9f4 100644 --- a/convlog.c +++ b/convlog.c @@ -79,7 +79,7 @@ void convlog(const char *arq, char df, int dfrom, int duntil) longline_destroy(&line); if (fclose(fp_in)==EOF) { - debuga(_("Failed to close file \"%s\": %s\n"),arq,strerror(errno)); + debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno)); exit(EXIT_FAILURE); } } diff --git a/dansguardian_log.c b/dansguardian_log.c index 399e684..54dff8c 100644 --- a/dansguardian_log.c +++ b/dansguardian_log.c @@ -82,6 +82,10 @@ void dansguardian_log(void) break; } } + if (fclose(fp_guard)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),DansGuardianConf,strerror(errno)); + exit(EXIT_FAILURE); + } if(debug) debuga(_("Reading DansGuardian log file: %s\n"),loglocation); @@ -140,8 +144,10 @@ void dansguardian_log(void) dansguardian_count++; } - if(fp_in) fclose(fp_in); - if(fp_guard) fclose(fp_guard); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),loglocation,strerror(errno)); + exit(EXIT_FAILURE); + } if (fclose(fp_ou)==EOF) { debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno)); exit(EXIT_FAILURE); diff --git a/dansguardian_report.c b/dansguardian_report.c index 57e0329..f768782 100644 --- a/dansguardian_report.c +++ b/dansguardian_report.c @@ -159,7 +159,10 @@ void dansguardian_report(void) output_html_link(fp_ou,url,100); fprintf(fp_ou,"%s\n",rule); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),dansguardian_in,strerror(errno)); + exit(EXIT_FAILURE); + } if(count>DansGuardianReportLimit && DansGuardianReportLimit>0) show_ignored_dansguardian(fp_ou,count-DansGuardianReportLimit); diff --git a/datafile.c b/datafile.c index 1a62f6b..c8489c7 100644 --- a/datafile.c +++ b/datafile.c @@ -190,7 +190,10 @@ void data_file(char *tmp) strcpy(oldacchora,acchora); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); } userinfo_stopscan(uscan); diff --git a/denied.c b/denied.c index 532ac6f..8b621de 100644 --- a/denied.c +++ b/denied.c @@ -262,7 +262,10 @@ void gen_denied_report(void) output_html_link(fp_ou,url,100); fputs("\n",fp_ou); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),denied_sort,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if(count>DeniedReportLimit && DeniedReportLimit>0) diff --git a/download.c b/download.c index d464cf3..b3ae0c1 100644 --- a/download.c +++ b/download.c @@ -296,7 +296,10 @@ void download_report(void) output_html_link(fp_ou,url,100); fputs("\n",fp_ou); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),report_in,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); fputs("\n",fp_ou); diff --git a/email.c b/email.c index 5f639c2..2055a63 100644 --- a/email.c +++ b/email.c @@ -102,7 +102,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema tnacc+=item.nacc; tnelap+=item.nelap; } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (olduser[0] != '\0') { @@ -249,7 +252,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",strip1," ",(uint64_t)avgacc,fixnum(tnbytes,1)," ",buildtime(avgelap),(uint64_t)avgelap); #endif - fclose(fp_top1); + if (fclose(fp_top1)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno)); + exit(EXIT_FAILURE); + } if (!KeepTempLog && unlink(top1)) { debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno)); exit(EXIT_FAILURE); @@ -273,7 +279,7 @@ 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)); + debuga(_("Read error in \"%s\": %s\n"),top3,strerror(errno)); exit(EXIT_FAILURE); } } else { diff --git a/exclude.c b/exclude.c index cebe191..edb2aa2 100644 --- a/exclude.c +++ b/exclude.c @@ -224,7 +224,10 @@ void gethexclude(const char *hexfile, int debug) } } - fclose(fp_ex); + if (fclose(fp_ex)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),hexfile,strerror(errno)); + exit(EXIT_FAILURE); + } return; } @@ -350,7 +353,10 @@ void getuexclude(const char *uexfile, int debug) strcat(excludeuser,"*END* "); - fclose(fp_ex); + if (fclose(fp_ex)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),uexfile,strerror(errno)); + exit(EXIT_FAILURE); + } return; } diff --git a/getconf.c b/getconf.c index 74bdeee..67fdf38 100644 --- a/getconf.c +++ b/getconf.c @@ -980,6 +980,9 @@ void getconf(void) } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno)); + exit(EXIT_FAILURE); + } return; } diff --git a/grepday.c b/grepday.c index 4d1321e..5ae9acc 100644 --- a/grepday.c +++ b/grepday.c @@ -720,7 +720,10 @@ void greport_day(const struct userinfostruct *uinfo) elappoints[day-1]+=elap; } } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno)); + exit(EXIT_FAILURE); + } if (snprintf(wdirname,sizeof(wdirname),"%s/%s/graph.html",outdirname,uinfo->filename)>=sizeof(wdirname)) { debuga(_("User name too long to manufacture file name ")); @@ -763,8 +766,10 @@ void greport_day(const struct userinfostruct *uinfo) fputs("\n",fp_ou); write_html_trailer(fp_ou); - if (fclose(fp_ou)==EOF) + if (fclose(fp_ou)==EOF) { debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno)); + exit(EXIT_FAILURE); + } #endif //HAVE_GD return; diff --git a/html.c b/html.c index 9f2371d..360c2a8 100644 --- a/html.c +++ b/html.c @@ -98,7 +98,10 @@ void htmlrel(void) strerror(errno)); exit(EXIT_FAILURE); } - fclose(fp_usr); + if (fclose(fp_usr)==EOF) { + debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno)); + exit(EXIT_FAILURE); + } } break; @@ -423,11 +426,14 @@ void htmlrel(void) } longline_destroy(&line1); - fclose(fp_ip); if (fclose(fp_ip2)==EOF) { debuga(_("Write error in \"%s\": %s\n"),tmp2,strerror(errno)); exit(EXIT_FAILURE); } + if (fclose(fp_ip)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),arqip,strerror(errno)); + exit(EXIT_FAILURE); + } if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2)>=sizeof(csort)) { debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3); @@ -497,7 +503,10 @@ void htmlrel(void) unelap+=userelap; } - fclose(fp_ip); + if (fclose(fp_ip)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line1); if (unlink(tmp3)) { @@ -527,7 +536,10 @@ void htmlrel(void) unelap=0; } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),arqin,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (iprel && arqip[0]) { @@ -594,7 +606,7 @@ void htmlrel(void) break; } if (fclose(fp_usr)==EOF) { - debuga(_("Write error in per user limit file %s: %s\n"),PerUserLimits[i].File,strerror(errno)); + debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno)); exit(EXIT_FAILURE); } user_limit[maskid]|=mask; diff --git a/index.c b/index.c index 0e176ca..feb44db 100644 --- a/index.c +++ b/index.c @@ -344,7 +344,8 @@ static long long int make_date_index_day(char *monthdir,int monthdir_size,int or monthdir[monthdir_len-1]='\0'; write_html_trailer(fp_ou); if (fclose(fp_ou)==EOF) { - debuga(_("Write error in %s/%s: %s\n"),monthdir,INDEX_HTML_FILE,strerror(errno)); + strcpy(monthdir+monthdir_len,INDEX_HTML_FILE); + debuga(_("Write error in \"%s\": %s\n"),monthdir,strerror(errno)); exit(EXIT_FAILURE); } return(total_size); @@ -513,7 +514,8 @@ static long long int make_date_index_month(char *yeardir,int yeardir_size,int or yeardir[yeardir_len-1]='\0'; write_html_trailer(fp_ou); if (fclose(fp_ou)==EOF) { - debuga(_("Write error in %s/%s: %s\n"),yeardir,INDEX_HTML_FILE,strerror(errno)); + strcpy(yeardir+yeardir_len,INDEX_HTML_FILE); + debuga(_("Write error in \"%s\": %s\n"),yeardir,strerror(errno)); exit(EXIT_FAILURE); } return(total_size); diff --git a/log.c b/log.c index a7a98bf..dc14bef 100644 --- a/log.c +++ b/log.c @@ -797,7 +797,10 @@ static void getusers(const char *pwdfile, int debug) strcat(userfile,buf); } - fclose(fp_usr); + if (fclose(fp_usr)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),pwdfile,strerror(errno)); + exit(EXIT_FAILURE); + } return; } diff --git a/readlog.c b/readlog.c index 6bf1a0f..cc7a828 100644 --- a/readlog.c +++ b/readlog.c @@ -664,7 +664,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq) if (ufile1->file!=NULL) { if (x>=maxopenfiles) { if (fclose(ufile1->file)==EOF) { - debuga(_("Write error in the log file of user %s: %s\n"),ufile1->user->id,strerror(errno)); + debuga(_("Write error in log file of user %s: %s\n"),ufile1->user->id,strerror(errno)); exit(EXIT_FAILURE); } ufile1->file=NULL; @@ -839,7 +839,7 @@ int ReadLogFile(struct ReadLogDataStruct *Filter) for (ufile=first_user_file ; ufile ; ufile=ufile1) { ufile1=ufile->next; if (ufile->file!=NULL && fclose(ufile->file)==EOF) { - debuga(_("Write error in the log file of user %s: %s\n"),ufile->user->id,strerror(errno)); + debuga(_("Write error in log file of user %s: %s\n"),ufile->user->id,strerror(errno)); exit(EXIT_FAILURE); } free(ufile); diff --git a/realtime.c b/realtime.c index 37e0dd2..0f15d55 100644 --- a/realtime.c +++ b/realtime.c @@ -242,7 +242,10 @@ void realtime(void) if (NextIndex>StoreSize) StoreSize=NextIndex; if (NextIndex>realtime_access_log_lines) NextIndex=0; } - fclose(fp); + if (fclose(fp)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),file_name,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); datashow(StoredLogEntries,StoreIndex,StoreSize); diff --git a/redirector.c b/redirector.c index f6379d1..c9b8464 100644 --- a/redirector.c +++ b/redirector.c @@ -277,7 +277,10 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) while ((buf=longline_read(fp_in,line)) != NULL) { parse_log(fp_ou,buf); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wentp,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); return; } @@ -373,9 +376,12 @@ void redirector_log(void) read_log(wentp,fp_ou,dfrom,duntil); } } + if (fclose(fp_guard)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),SquidGuardConf,strerror(errno)); + exit(EXIT_FAILURE); + } } - if (fp_guard) fclose(fp_guard); if (fp_ou && fclose(fp_ou)==EOF) { debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno)); exit(EXIT_FAILURE); @@ -561,7 +567,10 @@ void redirector_report(void) output_html_link(fp_ou,url,100); fprintf(fp_ou,"%s\n",rule); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),redirector_sorted,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if(count>SquidGuardReportLimit && SquidGuardReportLimit>0) diff --git a/repday.c b/repday.c index cb80880..20a4d6f 100644 --- a/repday.c +++ b/repday.c @@ -118,7 +118,10 @@ void report_day(const struct userinfostruct *uinfo) telap[i]+=elap; } } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno)); + exit(EXIT_FAILURE); + } if((fp_ou=fopen(arqout,"w"))==NULL) { debuga(_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno)); diff --git a/report.c b/report.c index 666432f..c64c37d 100644 --- a/report.c +++ b/report.c @@ -330,7 +330,10 @@ void gerarel(void) strcpy(oldaccdia,accdia); strcpy(oldacchora,acchora); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (oldurltt) free(oldurltt); if (oldurl) { @@ -349,7 +352,7 @@ void gerarel(void) } if (fp_tmp) { if (fclose(fp_tmp)==EOF) { - debuga(_("Failed to close temporary file for user %s: %s\n"),uinfo->filename,strerror(errno)); + debuga(_("Write error in \"%s\": %s\n"),uinfo->filename,strerror(errno)); exit(EXIT_FAILURE); } fp_tmp=NULL; diff --git a/siteuser.c b/siteuser.c index 5b0e681..410c6df 100644 --- a/siteuser.c +++ b/siteuser.c @@ -175,7 +175,10 @@ void siteuser(void) } } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if(regs>0) { diff --git a/splitlog.c b/splitlog.c index d6593b2..36bf660 100644 --- a/splitlog.c +++ b/splitlog.c @@ -141,7 +141,8 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons longline_destroy(&line); if (fclose(fp_in)==EOF) { - debuga(_("Failed to close file \"%s\": %s\n"),arq,strerror(errno)); + debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno)); + exit(EXIT_FAILURE); } if (autosplit && fp_ou) { if (fclose(fp_ou)==EOF) { diff --git a/topsites.c b/topsites.c index 664e25d..a41558f 100644 --- a/topsites.c +++ b/topsites.c @@ -162,7 +162,10 @@ void topsites(void) ttntime+=item.nelap; #endif } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (ourl) { @@ -316,7 +319,10 @@ void topsites(void) if (SortTableJs[0]) fprintf(fp_ou," sorttable_customkey=\"%d\"",nusers); fprintf(fp_ou,">%s\n",fixnum(nusers,1)); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),sites,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); fputs("\n",fp_ou); diff --git a/topuser.c b/topuser.c index 59fb9a8..3441c38 100644 --- a/topuser.c +++ b/topuser.c @@ -140,7 +140,10 @@ void topuser(void) tnincache+=item.incache; tnoucache+=item.oucache; } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (olduser[0] != '\0') { @@ -423,7 +426,10 @@ void topuser(void) topcount++; } - fclose(fp_top1); + if (fclose(fp_top1)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno)); + exit(EXIT_FAILURE); + } if (!KeepTempLog && unlink(top1)) { debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno)); exit(EXIT_FAILURE); diff --git a/url.c b/url.c index ca2318c..f24ce71 100644 --- a/url.c +++ b/url.c @@ -598,7 +598,10 @@ void read_hostalias(const char *Filename) } longline_destroy(&line); - fclose(fi); + if (fclose(fi)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno)); + exit(EXIT_FAILURE); + } if (debug) { struct hostalias_name *alias1; diff --git a/useragent.c b/useragent.c index ea9cf2a..8ea1140 100644 --- a/useragent.c +++ b/useragent.c @@ -122,11 +122,14 @@ void useragent(void) debuga(_(" Records read: %ld\n"),totregsl); } - fclose(fp_in); if (fclose(fp_ou)==EOF) { debuga(_("Write error in \"%s\": %s\n"),tmp3,strerror(errno)); exit(EXIT_FAILURE); } + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),UserAgentLog,strerror(errno)); + exit(EXIT_FAILURE); + } if(debug) { debuga(_("Sorting file: %s\n"),tmp2); @@ -213,7 +216,10 @@ void useragent(void) } fputs("\n",fp_ht); - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp2,strerror(errno)); + exit(EXIT_FAILURE); + } if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) { debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3); @@ -273,11 +279,14 @@ void useragent(void) fprintf(fp_ou,"%06d %s\n",agentot,agent); agentot2+=agentot; - fclose(fp_in); if (fclose(fp_ou)==EOF) { debuga(_("Write error in \"%s\": %s\n"),tmp3,strerror(errno)); exit(EXIT_FAILURE); } + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno)); + exit(EXIT_FAILURE); + } if (!KeepTempLog && unlink(tmp3)) { debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno)); @@ -325,7 +334,10 @@ void useragent(void) output_html_string(fp_ht,gwarea.current,250); fprintf(fp_ht,"%d%3.2lf\n",nagent,perc); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno)); + exit(EXIT_FAILURE); + } fputs("\n",fp_ht); write_html_trailer(fp_ht); diff --git a/userinfo.c b/userinfo.c index e87db5e..6f9ac91 100644 --- a/userinfo.c +++ b/userinfo.c @@ -342,7 +342,10 @@ void read_useralias(const char *Filename) } longline_destroy(&line); - fclose(fi); + if (fclose(fi)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno)); + exit(EXIT_FAILURE); + } if (debug) { debuga(_("List of user names to alias:\n")); diff --git a/usertab.c b/usertab.c index 5e6aa82..40c08ec 100644 --- a/usertab.c +++ b/usertab.c @@ -123,7 +123,10 @@ static void init_file_usertab(const char *UserTabFile) userfile[z2++]='\t'; } userfile[z2]='\0'; - fclose(fp_usr); + if (fclose(fp_usr)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),UserTabFile,strerror(errno)); + exit(EXIT_FAILURE); + } } static void get_usertab_name(const char *user,char *name,int namelen) diff --git a/util.c b/util.c index 957b464..12b14ff 100644 --- a/util.c +++ b/util.c @@ -793,7 +793,10 @@ int obtdate(const char *dirname, const char *name, char *data) debuga(_("Failed to read the date in %s\n"),wdir); exit(EXIT_FAILURE); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno)); + exit(EXIT_FAILURE); + } fixendofline(data); return(0); @@ -857,7 +860,10 @@ int obtuser(const char *dirname, const char *name) debuga(_("Failed to read the number of users in %s\n"),wdir); exit(EXIT_FAILURE); } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno)); + exit(EXIT_FAILURE); + } nuser=atoi(tuser); return(nuser); @@ -922,7 +928,10 @@ void obttotal(const char *dirname, const char *name, int nuser, long long int *t } break; } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno)); + exit(EXIT_FAILURE); + } longline_destroy(&line); if (nuser <= 0) @@ -1132,12 +1141,15 @@ static void copy_images(void) } } if (fclose(img_ou)==EOF) { - debuga(_("Error while copying image %s: %s\n"),dstfile,strerror(errno)); + debuga(_("Write error in \"%s\": %s\n"),dstfile,strerror(errno)); exit(EXIT_FAILURE); } } else debuga(_("Cannot open file \"%s\": %s\n"), dstfile, strerror(errno)); - fclose(img_in); + if (fclose(img_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),srcfile,strerror(errno)); + exit(EXIT_FAILURE); + } } else debuga(_("Cannot open file \"%s\": %s\n"), srcfile, strerror(errno)); } @@ -1447,7 +1459,7 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site, exit(EXIT_FAILURE); } if (fclose(fp_ou)==EOF) { - debuga(_("Failed to write the date in %s: %s\n"),wdir,strerror(errno)); + debuga(_("Write error in \"%s\": %s\n"),wdir,strerror(errno)); exit(EXIT_FAILURE); } @@ -1725,7 +1737,7 @@ void removetmp(const char *outdir) } totalger(fp_gen,filename); if (fclose(fp_gen)==EOF) { - debuga(_("Failed to close %s after writing the total line: %s\n"),filename,strerror(errno)); + debuga(_("Write error in \"%s\": %s\n"),filename,strerror(errno)); exit(EXIT_FAILURE); } } @@ -1781,7 +1793,10 @@ void load_excludecodes(const char *ExcludeCodes) Stored+=i+1; } - fclose(fp_in); + if (fclose(fp_in)==EOF) { + debuga(_("Read error in \"%s\": %s\n"),ExcludeCodes,strerror(errno)); + exit(EXIT_FAILURE); + } return; } -- 2.47.2