From: Serge Hallyn Date: Wed, 22 Jan 2014 19:16:59 +0000 (-0600) Subject: lxcapi_get_interfaces and lxcapi_get_ips: stricter read check X-Git-Tag: lxc-1.0.0.beta3~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=358afd840d713d9568a13631883fa0c32de5c868;p=thirdparty%2Flxc.git lxcapi_get_interfaces and lxcapi_get_ips: stricter read check Coverity warns of the danger of a short read otherwise. (Untested, but should be correct; Tossing over to you :) Signed-off-by: Serge Hallyn Cc: S.Çağlar Onur Acked-by: S.Çağlar Onur --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 4ffd9a94a..70a85bdf4 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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++;