[lxc-devel] [PATCH 1/1] lxcapi_get_interfaces and lxcapi_get_ips: stricter read check

S.Çağlar Onur caglar at 10ur.org
Wed Jan 22 19:30:51 UTC 2014


On Wed, Jan 22, 2014 at 2:19 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> Coverity warns of the danger of a short read otherwise.
>
> (Untested, but should be correct; Tossing over to you :)
>
> Cc: S.Çağlar Onur <caglar at 10ur.org>
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: S.Çağlar Onur <caglar at 10ur.org>

> ---
>  src/lxc/lxccontainer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 4ffd9a9..70a85bd 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++;
> --
> 1.8.5.3
>



-- 
S.Çağlar Onur <caglar at 10ur.org>


More information about the lxc-devel mailing list