[lxc-devel] [lxc/master] coverity: #1425778

2xsec on Github lxc-bot at linuxcontainers.org
Thu Jun 14 15:21:33 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 369 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180614/b51599c3/attachment.bin>
-------------- next part --------------
From 40229e9533ad85e399ff4c44448020d99cc4abae Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Fri, 15 Jun 2018 00:19:22 +0900
Subject: [PATCH] coverity: #1425778

Out-of-bounds write

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/lxc/criu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lxc/criu.c b/src/lxc/criu.c
index 1ff4caef8..eab650d7e 100644
--- a/src/lxc/criu.c
+++ b/src/lxc/criu.c
@@ -1314,7 +1314,11 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
 			SYSERROR("read");
 			n = 0;
 		}
-		buf[n] = 0;
+
+		if (n == sizeof(buf))
+			buf[n-1] = 0;
+		else
+			buf[n] = 0;
 
 		if (WIFEXITED(status)) {
 			if (WEXITSTATUS(status)) {


More information about the lxc-devel mailing list