[lxc-devel] [PATCH] Check return value of snprintf in mount_proc_if_needed()
Christian Brauner
christianvanbrauner at gmail.com
Sun Sep 27 08:32:28 UTC 2015
Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>
---
src/lxc/utils.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index 0b83960..8e7fc52 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -1431,6 +1431,10 @@ int mount_proc_if_needed(const char *rootfs)
mypid = (int)getpid();
INFO("I am %d, /proc/self points to '%s'", mypid, link);
ret = snprintf(path, MAXPATHLEN, "%s/proc", rootfs);
+ if (ret < 0 || ret >= MAXPATHLEN) {
+ SYSERROR("proc path name too long");
+ return -1;
+ }
if (linklen < 0) /* /proc not mounted */
goto domount;
if (atoi(link) != mypid) {
--
2.5.3
More information about the lxc-devel
mailing list