From 4e4d5fbaa3be5dadbb1f879a113d720521cbef51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Sun, 15 Jul 2012 14:29:05 +0200 Subject: [PATCH] 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. --- html.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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); } -- 2.47.2