mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-11 04:12:39 +02:00
imfile: fix file handle leak under OOM condition
very unlikely; detected by Coverity Scan, CID 193442
This commit is contained in:
parent
d63ed4df54
commit
b578791540
@ -691,6 +691,7 @@ act_obj_add(fs_edge_t *const edge, const char *const name, const int is_file,
|
||||
act_obj_t *act;
|
||||
char basename[MAXFNAME];
|
||||
DEFiRet;
|
||||
int fd = -1;
|
||||
|
||||
DBGPRINTF("act_obj_add: edge %p, name '%s' (source '%s')\n", edge, name, source? source : "---");
|
||||
for(act = edge->active ; act != NULL ; act = act->next) {
|
||||
@ -703,7 +704,7 @@ act_obj_add(fs_edge_t *const edge, const char *const name, const int is_file,
|
||||
}
|
||||
}
|
||||
DBGPRINTF("need to add new active object '%s' in '%s' - checking if accessible\n", name, edge->path);
|
||||
const int fd = open(name, O_RDONLY | O_CLOEXEC);
|
||||
fd = open(name, O_RDONLY | O_CLOEXEC);
|
||||
if(fd < 0) {
|
||||
LogMsg(errno, RS_RET_ERR, LOG_WARNING, "imfile: error accessing file '%s'", name);
|
||||
FINALIZE;
|
||||
@ -751,6 +752,9 @@ finalize_it:
|
||||
free(act->name);
|
||||
free(act);
|
||||
}
|
||||
if(fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user