file: reserve one byte in a string buffer for the null byte

*** CID 139492:  Memory - illegal accesses  (BUFFER_SIZE_WARNING)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2015-09-01 10:47:29 +03:00 committed by Pavel Emelyanov
parent f62fd61709
commit 35ec944304

View file

@ -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);