[lxc-devel] [lxc/master] storage: src cannot be truncated

brauner on Github lxc-bot at linuxcontainers.org
Tue Dec 11 10:37:48 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 387 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181211/9d38be69/attachment.bin>
-------------- next part --------------
From 2970e75408559d99ec3d5f5f393c9020a0698cb5 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 11 Dec 2018 11:36:54 +0100
Subject: [PATCH] storage: src cannot be truncated

s/strlcpy/strncpy/g

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/storage/storage_utils.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/lxc/storage/storage_utils.c b/src/lxc/storage/storage_utils.c
index fa4e7270bd..8bf55c52bd 100644
--- a/src/lxc/storage/storage_utils.c
+++ b/src/lxc/storage/storage_utils.c
@@ -95,14 +95,8 @@ char *dir_new_path(char *src, const char *oldname, const char *name,
 	}
 
 	while ((p2 = strstr(src, oldname)) != NULL) {
-		size_t retlen;
-
 		/* copy text up to oldname */
-		retlen = strlcpy(p, src, p2 - src);
-		if (retlen >= p2 - src) {
-			free(ret);
-			return NULL;
-		}
+		strncpy(p, src, p2 - src);
 
 		/* move target pointer (p) */
 		p += p2 - src;


More information about the lxc-devel mailing list