diff options
author | Xin LI <delphij@FreeBSD.org> | 2010-08-19 01:34:00 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2010-08-19 01:34:00 +0000 |
commit | c38fa7e016711fbb846c355ea567a2d6ab52ee3c (patch) | |
tree | 1678d644df6bc40bedbfe2fd561359210c018929 /usr.bin/gzip | |
parent | af8ec89da4861848686fd42ec962672defc71d50 (diff) | |
download | src-c38fa7e016711fbb846c355ea567a2d6ab52ee3c.tar.gz src-c38fa7e016711fbb846c355ea567a2d6ab52ee3c.zip |
Check return value of dup(), it could be -1 when the system is running
out of file descriptors for instance.
Found with: Coverity Prevent(tm)
CID: 6084
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=211475
Diffstat (limited to 'usr.bin/gzip')
-rw-r--r-- | usr.bin/gzip/unpack.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/gzip/unpack.c b/usr.bin/gzip/unpack.c index aa1480016d28..cc717a6a95eb 100644 --- a/usr.bin/gzip/unpack.c +++ b/usr.bin/gzip/unpack.c @@ -312,7 +312,14 @@ unpack(int in, int out, char *pre, size_t prelen, off_t *bytes_in) { unpack_descriptor_t unpackd; - unpack_parse_header(dup(in), dup(out), pre, prelen, bytes_in, &unpackd); + in = dup(in); + if (in == -1) + maybe_err("dup"); + out = dup(out); + if (out == -1) + maybe_err("dup"); + + unpack_parse_header(in, out, pre, prelen, bytes_in, &unpackd); unpack_decode(&unpackd, bytes_in); unpack_descriptor_fini(&unpackd); |