From bd40aea7d1d0f38a0746026d717b0a65fe52a8d8 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Fri, 1 Sep 2017 18:51:20 +0300 Subject: [PATCH] Checking the return value of fstat(). Just to make sure and to make Coverity Scan happy. --- njs/njs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/njs/njs.c b/njs/njs.c index 5670e0f0..d6fe03c7 100644 --- 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); } -- 2.47.3