[lxc-devel] [PATCH] Check return value of snprintf

Christian Brauner christianvanbrauner at gmail.com
Sun Sep 27 08:17:34 UTC 2015


Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>
---
 src/lxc/lxc_destroy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lxc/lxc_destroy.c b/src/lxc/lxc_destroy.c
index 39e289c..0eeff51 100644
--- a/src/lxc/lxc_destroy.c
+++ b/src/lxc/lxc_destroy.c
@@ -152,6 +152,8 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
 
 	/* Destroy snapshots created with lxc-clone listed in lxc-snapshots. */
 	ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
+	if (ret < 0 || ret >= MAXPATHLEN)
+		return -1;
 
 	fd = open(path, O_RDONLY | O_CLOEXEC);
 	if (fd >= 0) {
-- 
2.5.3



More information about the lxc-devel mailing list