]> git.kaiwu.me - njs.git/commitdiff
Checking the return value of fstat().
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 1 Sep 2017 15:51:20 +0000 (18:51 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 1 Sep 2017 15:51:20 +0000 (18:51 +0300)
Just to make sure and to make Coverity Scan happy.

njs/njs.c

index 5670e0f0d6e7ca814ec0d02044cd8c09fb5d6b24..d6fe03c74f770c12c02880de0389e67aac2f0dc6 100644 (file)
--- a/njs/njs.c
+++ b/njs/njs.c
@@ -323,7 +323,12 @@ njs_process_file(njs_opts_t *opts, njs_vm_opt_t *vm_options)
         }
     }
 
-    fstat(fd, &sb);
+    if (fstat(fd, &sb) == -1) {
+        fprintf(stderr, "fstat(%d) failed while reading '%s' (%s)\n",
+                fd, file, strerror(errno));
+        ret = NXT_ERROR;
+        goto close_fd;
+    }
 
     size = sizeof(buf);
 
@@ -407,6 +412,8 @@ done:
         free(script.start);
     }
 
+close_fd:
+
     if (fd != STDIN_FILENO) {
         close(fd);
     }