From: Frédéric Marchal Date: Sun, 15 Jul 2012 12:29:05 +0000 (+0200) Subject: A temporary file could be left in place by sarg X-Git-Tag: v2.3.3~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e4d5fbaa3be5dadbb1f879a113d720521cbef51;p=thirdparty%2Fsarg.git A temporary file could be left in place by sarg During the creation of the user's reports, if the report showing the details by date and hour is not requested, the unnecessary file is deleted but it overwrite the buffer containing the name of another temporary file to delete. As the file name is overwritten, it cannot be deleted when the function completes. --- diff --git a/html.c b/html.c index c6ef899..08ab1f6 100644 --- a/html.c +++ b/html.c @@ -325,9 +325,9 @@ void htmlrel(void) count++; } else if ((ReportType & REPORT_TYPE_SITE_USER_TIME_DATE) != 0) { url_to_file(url,siteind,sizeof(siteind)); - snprintf(tmp2,sizeof(tmp2),"%s/%s/tt%s-%s.html",outdirname,uinfo->filename,uinfo->filename,siteind); - if (unlink(tmp2)!=0) { - debuga(_("Cannot delete unused file \"%s\" - %s\n"),tmp2,strerror(errno)); + snprintf(warea,sizeof(warea),"%s/%s/tt%s-%s.html",outdirname,uinfo->filename,uinfo->filename,siteind); + if (unlink(warea)!=0) { + debuga(_("Cannot delete \"%s\": %s\n"),warea,strerror(errno)); } } @@ -401,6 +401,11 @@ void htmlrel(void) exit(EXIT_FAILURE); } + if (unlink(tmp2)) { + debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno)); + exit(EXIT_FAILURE); + } + olduserip[0]='\0'; if ((line1=longline_create())==NULL) { @@ -451,12 +456,8 @@ void htmlrel(void) fclose(fp_ip); longline_destroy(&line1); - if (unlink(tmp2)) { - debuga(_("Cannot delete %s - %s\n"),tmp2,strerror(errno)); - exit(EXIT_FAILURE); - } if (unlink(tmp3)) { - debuga(_("Cannot delete %s - %s\n"),tmp3,strerror(errno)); + debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno)); exit(EXIT_FAILURE); }