Commit 1934e1a9 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

posix-timer: take into account that sival_ptr can be NULL (v3)

ID: 0
signal: 26/          (null)
notify: signal/pid.5954
ClockID: 1

fscanf "%p" doesn't handle "(null)".

https://bugzilla.openvz.org/show_bug.cgi?id=2894

v2: make the original scanf be %d/%s and then additionally
    parse the obtained string
v3: don't use strstr
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ef98f96c
......@@ -1315,16 +1315,17 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
}
while (1) {
char pbuf[17]; /* 16 + eol */
timer = xzalloc(sizeof(struct proc_posix_timer));
if (timer == NULL)
goto err;
ret = fscanf(file, "ID: %ld\n"
"signal: %d/%p\n"
"signal: %d/%16s\n"
"notify: %6[a-z]/%3[a-z].%d\n"
"ClockID: %d\n",
&timer->spt.it_id,
&timer->spt.si_signo, &timer->spt.sival_ptr,
&timer->spt.si_signo, pbuf,
sigpid, tidpid, &pid_t,
&timer->spt.clock_id);
if (ret != 7) {
......@@ -1335,6 +1336,14 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
goto err;
}
timer->spt.sival_ptr = NULL;
if (sscanf(pbuf, "%p", &timer->spt.sival_ptr) != 1 &&
strcmp(pbuf, "(null)")) {
pr_err("Unable to parse '%s'\n", pbuf);
xfree(timer);
goto err;
}
if ( tidpid[0] == 't') {
timer->spt.it_sigev_notify = SIGEV_THREAD_ID;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment