also fix the check if the string will fit the local buffer

Signed-off-by: Dwight Engen <[email protected]>
---
 src/lxc/cgmanager.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
index 41ba3d3..e4bd734 100644
--- a/src/lxc/cgmanager.c
+++ b/src/lxc/cgmanager.c
@@ -422,8 +422,10 @@ static inline bool cgm_create(void *hdata)
        tmp = lxc_string_replace("%n", d->name, d->cgroup_pattern);
        if (!tmp)
                return false;
-       if (strlen(tmp) > MAXPATHLEN)
+       if (strlen(tmp) >= MAXPATHLEN) {
+               free(tmp);
                return false;
+       }
        strcpy(result, tmp);
        baselen = strlen(result);
        free(tmp);
-- 
1.8.5.3

_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to