]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands.c: sanity check to not write too-long cgroup path name
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 14 Mar 2013 02:19:24 +0000 (21:19 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 14 Mar 2013 02:19:24 +0000 (21:19 -0500)
This can't really happen due to current limits in cgroup.c but add it
in case those change in the future.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/commands.c

index de9a7c45ed7b22958423b76b9691d9e397da2bd4..f18fe9e8a807f9bda9fe1e3f29cd93f59b01fd6e 100644 (file)
@@ -91,6 +91,10 @@ static int receive_answer(int sock, struct lxc_answer *answer)
                ERROR("failed to receive answer for the command");
        if (answer->pathlen == 0)
                return ret;
+       if (answer->pathlen >= MAXPATHLEN) {
+               ERROR("cgroup path was too long");
+               return -1;
+       }
        ret = recv(sock, answerpath, answer->pathlen, 0);
        if (ret != answer->pathlen) {
                ERROR("failed to receive answer for the command");