check against -1 to appease coverity.
authorChristos Zoulas <christos@zoulas.com>
Wed, 1 Aug 2018 09:56:24 +0000 (09:56 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 1 Aug 2018 09:56:24 +0000 (09:56 +0000)
src/readelf.c

index 2bcbc59dd3472f8dd70c5cdb4ab1aa754584cffd..5dfcea544889f130c50ae55c93f64c4f6423e725 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.146 2018/07/27 07:50:14 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.147 2018/08/01 09:56:24 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -1716,7 +1716,7 @@ file_tryelf(struct magic_set *ms, const struct buffer *b)
            && (errno == ESPIPE))
                fd = file_pipe2file(ms, fd, buf, nbytes);
 
-       if (fstat(fd, &st) == -1) {
+       if (fd == -1 || fstat(fd, &st) == -1) {
                file_badread(ms);
                return -1;
        }