[CRIU] [PATCH 3/3] zdtm: don't write out of bounds

Andrei Vagin avagin at openvz.org
Fri Jan 20 12:21:27 PST 2017


From: Andrei Vagin <avagin at virtuozzo.com>

CID 174800 (#1 of 1): Out-of-bounds write (OVERRUN)
5. overrun-local: Overrunning array buf of 1024 bytes at byte offset 1024 using index n (which evaluates to 1024).

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/cgroup04.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/zdtm/static/cgroup04.c b/test/zdtm/static/cgroup04.c
index 57dbb20..812a9a3 100644
--- a/test/zdtm/static/cgroup04.c
+++ b/test/zdtm/static/cgroup04.c
@@ -93,7 +93,7 @@ bool checkval(char *path, char *val)
 		return false;
 	}
 
-	n = read(fd, buf, sizeof(buf));
+	n = read(fd, buf, sizeof(buf) - 1);
 	close(fd);
 	if (n < 0) {
 		pr_perror("read");
-- 
2.7.4



More information about the CRIU mailing list