From: Christos Zoulas Date: Wed, 7 Nov 2012 17:54:48 +0000 (+0000) Subject: check the return value of dup(2) X-Git-Tag: FILE5_12~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a2db81de8a5238a8d6688dfc7348a65dd26fe36;p=file check the return value of dup(2) --- diff --git a/src/compress.c b/src/compress.c index 91c69a16..22960808 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.68 2011/12/08 12:38:24 rrt Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.69 2012/08/26 10:21:37 christos Exp $") #endif #include "magic.h" @@ -397,16 +397,19 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, case 0: /* child */ (void) close(0); if (fd != -1) { - (void) dup(fd); + if (dup(fd) == -1) + _exit(1); (void) lseek(0, (off_t)0, SEEK_SET); } else { - (void) dup(fdin[0]); + if (dup(fdin[0]) == -1) + _exit(1); (void) close(fdin[0]); (void) close(fdin[1]); } (void) close(1); - (void) dup(fdout[1]); + if (dup(fdout[1]) == -1) + _exit(1); (void) close(fdout[0]); (void) close(fdout[1]); #ifndef DEBUG