From 40229e9533ad85e399ff4c44448020d99cc4abae Mon Sep 17 00:00:00 2001 From: 2xsec Date: Fri, 15 Jun 2018 00:19:22 +0900 Subject: [PATCH] coverity: #1425778 Out-of-bounds write Signed-off-by: 2xsec --- 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 1ff4caef8d..eab650d7e3 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)) {