[lxc-devel] [PATCH 3/6] coverity: Check fstat return value
Serge Hallyn
serge.hallyn at ubuntu.com
Sat Feb 15 00:00:44 UTC 2014
Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> ---
> src/lxc/lxc_user_nic.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c
> index 60176b1..a2f0c96 100644
> --- a/src/lxc/lxc_user_nic.c
> +++ b/src/lxc/lxc_user_nic.c
> @@ -306,7 +306,10 @@ static bool cull_entries(int fd, char *me, char *t, char *br)
>
> nic = alloca(100);
>
> - fstat(fd, &sb);
> + if (fstat(fd, &sb) < 0) {
> + fprintf(stderr, "Failed to fstat: %s", strerror(errno));
> + return false;
> + }
> len = sb.st_size;
> if (len == 0)
> return true;
> @@ -383,7 +386,10 @@ static bool get_nic_if_avail(int fd, char *me, int pid, char *intype, char *br,
> if (allowed == 0)
> return false;
>
> - fstat(fd, &sb);
> + if (fstat(fd, &sb) < 0) {
> + fprintf(stderr, "Failed to fstat: %s", strerror(errno));
> + return false;
> + }
> len = sb.st_size;
> if (len != 0) {
> buf = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
> --
> 1.9.rc1
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
More information about the lxc-devel
mailing list