[lxc-devel] [lxc/master] fix the return value check of snprintf

JingWoo on Github lxc-bot at linuxcontainers.org
Sat Jul 18 12:39:07 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 344 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200718/226d2c42/attachment.bin>
-------------- next part --------------
From 29497e0583e0449428a1a821fe21cdb6f040b26a Mon Sep 17 00:00:00 2001
From: wujing <wujing50 at huawei.com>
Date: Sat, 18 Jul 2020 20:18:16 +0800
Subject: [PATCH] fix the return value check of snprintf

Signed-off-by: wujing <wujing50 at huawei.com>
---
 src/lxc/commands_utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/commands_utils.c b/src/lxc/commands_utils.c
index 2af722ca12..184e9afee2 100644
--- a/src/lxc/commands_utils.c
+++ b/src/lxc/commands_utils.c
@@ -117,7 +117,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen,
 	}
 
 	ret = snprintf(offset, len, "%s/%s/%s", lxcpath, name, suffix);
-	if (ret < 0)
+	if (ret < 0 || (size_t)ret >= len)
 		return log_error_errno(-1, errno, "Failed to create abstract socket name");
 
 	/*


More information about the lxc-devel mailing list