Skip to content

Commit

Permalink
rotateSingleLog: free savedContext when setSecCtxByName fails
Browse files Browse the repository at this point in the history
```
Error: RESOURCE_LEAK (CWE-772):
logrotate-3.18.0/logrotate.c:2032: alloc_arg: "setSecCtxByName" allocates memory that is stored into "savedContext".
logrotate-3.18.0/logrotate.c:2034: leaked_storage: Variable "savedContext" going out of scope leaks the storage it points to.
```
  • Loading branch information
jamacku committed Mar 14, 2024
1 parent dd31599 commit 7f8324a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions logrotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,7 @@ static int rotateSingleLog(const struct logInfo *log, unsigned logNum,
if (!(log->flags & (LOG_FLAG_COPYTRUNCATE | LOG_FLAG_COPY))) {
if (setSecCtxByName(log->files[logNum], log, &savedContext) != 0) {
/* error msg already printed */
freecon(savedContext);
return 1;
}
#ifdef WITH_ACL
Expand Down

0 comments on commit 7f8324a

Please sign in to comment.