]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
A temporary file could be left in place by sarg
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 12:29:05 +0000 (14:29 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 12:29:05 +0000 (14:29 +0200)
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

diff --git a/html.c b/html.c
index c6ef89993942803b1946aec552abb922349679c5..08ab1f678ea4bbd88ea4f56a5b0ef7655d01d99b 100644 (file)
--- 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);
                                }