[CRIU] [PATCH] seize: fix memory corruption

Andrey Vagin avagin at openvz.org
Mon Jul 18 11:23:32 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

277                     }
>>>     CID 164718:  Memory - corruptions  (OVERRUN)
>>>     Overrunning array "stackbuf" of 2048 bytes at byte offset 2048 using index "ret" (which evaluates to 2048).
278                     stackbuf[ret] = '\0';

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/seize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/seize.c b/criu/seize.c
index 9d27e8d..78cc1f8 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -270,7 +270,7 @@ static int log_unfrozen_stacks(char *root)
 			return -1;
 		}
 
-		ret = read(stack, stackbuf, sizeof(stackbuf));
+		ret = read(stack, stackbuf, sizeof(stackbuf) - 1);
 		close(stack);
 		if (ret < 0) {
 			pr_perror("couldn't read %d's stack", pid);
-- 
2.7.4



More information about the CRIU mailing list