Skip to content

Commit 4419699

Browse files
committed
Handle errors returned by msg_handler
This change handles errors returned by msg_handler. It prevents the probe_worker_runfn function from crashing, when msg_handler returns NULL and the probe_res pointer is dereferenced. For example, the probe_worker function could return NULL when calling chroot without root privileges.
1 parent ec072be commit 4419699

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/OVAL/probes/probe/worker.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ void *probe_worker_runfn(void *arg)
103103
//
104104
dD("handler result = %p, return code = %d", probe_res, probe_ret);
105105

106+
if (probe_res == NULL) {
107+
dE("An error was returned by the input message handler: %s.", strerror(errno));
108+
exit(1);
109+
}
110+
106111
/* Assuming that the red-black tree API is doing locking for us... */
107112
if (rbt_i32_del(pair->probe->workers, pair->pth->sid, NULL) != 0) {
108113
dW("thread not found in the probe thread tree, probably canceled by an external signal");

0 commit comments

Comments
 (0)