[lxc-devel] [lxc/master] cgfsng: fix off-by-one error

brauner on Github lxc-bot at linuxcontainers.org
Thu Feb 22 00:29:06 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180222/f14848e5/attachment.bin>
-------------- next part --------------
From cbe2185b8118103b07b10003bfb690f97bcebd78 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 22 Feb 2018 01:28:20 +0100
Subject: [PATCH] cgfsng: fix off-by-one error

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index c2d94b7d3..b614a094d 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -257,8 +257,8 @@ static char *cg_legacy_must_prefix_named(char *entry)
 	len = strlen(entry);
 	prefixed = must_alloc(len + 6);
 
-	memcpy(prefixed, "name=", sizeof("name="));
-	memcpy(prefixed + sizeof("name="), entry, len);
+	memcpy(prefixed, "name=", sizeof("name=") - 1);
+	memcpy(prefixed + sizeof("name=") - 1, entry, len);
 	prefixed[len + 5] = '\0';
 	return prefixed;
 }


More information about the lxc-devel mailing list