From: Frédéric Marchal Date: Fri, 31 Aug 2012 16:58:54 +0000 (+0200) Subject: Add a safety to prevent the deletion of files that haven't been created X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab7f8e508625e3b352e2d2254d8bc998e8cfb0d6;p=thirdparty%2Fsarg.git Add a safety to prevent the deletion of files that haven't been created There was a path in the source code where sarg could try to delete the temporary unsorted files of the denied and authfail reports without checking that the file names were not empty. The functions where the guard was added are not supposed to be called if no reports are to be generated but that check relies on the caller. If the caller fails and call the function to generate the reports, it will try to delete a file whose name is empty. --- diff --git a/authfail.c b/authfail.c index 60b4657..dd15e69 100644 --- a/authfail.c +++ b/authfail.c @@ -138,7 +138,7 @@ void authfail_report(void) struct tm t; if (!authfail_exists) { - if (!KeepTempLog && unlink(authfail_unsort)) + if (!KeepTempLog && authfail_unsort[0]!='\0' && unlink(authfail_unsort)) debuga(_("Failed to delete \"%s\": %s\n"),authfail_unsort,strerror(errno)); authfail_unsort[0]='\0'; diff --git a/denied.c b/denied.c index 701d744..b09c41b 100644 --- a/denied.c +++ b/denied.c @@ -140,7 +140,7 @@ void gen_denied_report(void) struct tm t; if (!denied_exists) { - if (!KeepTempLog && unlink(denied_unsort)) + if (!KeepTempLog && denied_unsort[0]!='\0' && unlink(denied_unsort)) debuga(_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno)); denied_unsort[0]='\0'; if (debugz) debugaz(_("Denied report not produced because it is empty\n"));