[CRIU] [PATCH 2/3] file: reserve one byte in a string buffer for the null byte

Andrey Vagin avagin at openvz.org
Tue Sep 1 00:47:29 PDT 2015


*** CID 139492:  Memory - illegal accesses  (BUFFER_SIZE_WARNING)
---
 files.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/files.c b/files.c
index 3848acf..af1c0f3 100644
--- a/files.c
+++ b/files.c
@@ -197,7 +197,7 @@ static int fixup_overlayfs(struct fd_parms *p, struct fd_link *link)
 		char buf[PATH_MAX];
 		int n;
 
-		strncpy(buf, link->name, PATH_MAX);
+		strncpy(buf, link->name, PATH_MAX - 1);
 		n = snprintf(link->name, PATH_MAX, "%s/%s", m->mountpoint, buf + 2);
 		if (n >= PATH_MAX) {
 			pr_err("Not enough space to replace %s\n", buf);
-- 
2.4.3



More information about the CRIU mailing list