]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxcapi_get_interfaces and lxcapi_get_ips: stricter read check
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 22 Jan 2014 19:16:59 +0000 (13:16 -0600)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 22 Jan 2014 19:57:00 +0000 (13:57 -0600)
Coverity warns of the danger of a short read otherwise.

(Untested, but should be correct; Tossing over to you :)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: S.Çağlar Onur <caglar@10ur.org>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
src/lxc/lxccontainer.c

index 4ffd9a94ae68572bb4363b8656d76ecfe20324c1..70a85bdf42d344d5d3beb41f361b418c1d8d0a6e 100644 (file)
@@ -1556,7 +1556,7 @@ static char** lxcapi_get_interfaces(struct lxc_container *c)
        /* close the write-end of the pipe */
        close(pipefd[1]);
 
-       while (read(pipefd[0], &interface, IFNAMSIZ) > 0) {
+       while (read(pipefd[0], &interface, IFNAMSIZ) == IFNAMSIZ) {
                if (array_contains(&interfaces, interface, count))
                                continue;
 
@@ -1676,7 +1676,7 @@ static char** lxcapi_get_ips(struct lxc_container *c, const char* interface, con
        /* close the write-end of the pipe */
        close(pipefd[1]);
 
-       while (read(pipefd[0], &address, INET6_ADDRSTRLEN) > 0) {
+       while (read(pipefd[0], &address, INET6_ADDRSTRLEN) == INET6_ADDRSTRLEN) {
                if(!add_to_array(&addresses, address, count))
                        ERROR("PARENT: add_to_array failed");
                count++;