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.
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';
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"));