coverity 83659 plat unix check fstat return
authorAndy Green <andy.green@linaro.org>
Sun, 30 Nov 2014 05:03:45 +0000 (13:03 +0800)
committerAndy Green <andy.green@linaro.org>
Sun, 30 Nov 2014 05:10:26 +0000 (13:10 +0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/lws-plat-unix.c

index cc1c125..e81bb1e 100644 (file)
@@ -423,7 +423,10 @@ lws_plat_open_file(const char* filename, unsigned long* filelen)
        if (ret < 0)
                return LWS_INVALID_FILE;
 
-       fstat(ret, &stat_buf);
+       if (fstat(ret, &stat_buf) < 0) {
+               close(ret);
+               return LWS_INVALID_FILE;
+       }
        *filelen = stat_buf.st_size;
        return ret;
 }