[CRIU] [PATCH] posix-timer: take into account that sival_ptr can be NULL (v2)

Andrey Vagin avagin at openvz.org
Tue Feb 18 02:07:21 PST 2014


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

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 proc_parse.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index 26dd9c4..5ecdc22 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1277,16 +1277,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) {
@@ -1297,6 +1298,13 @@ 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 &&
+		    strstr(pbuf, "(null)") == NULL) {
+			xfree(timer);
+			goto err;
+		}
+
 		if ( tidpid[0] == 't') {
 			timer->spt.it_sigev_notify = SIGEV_THREAD_ID;
 		} else {
-- 
1.8.5.3



More information about the CRIU mailing list