summaryrefslogtreecommitdiffstats
path: root/usr.bin/gzip
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-08-19 01:34:00 +0000
committerdelphij <delphij@FreeBSD.org>2010-08-19 01:34:00 +0000
commit9a8b3cac780596343c946cecea69c661e3615e12 (patch)
tree1678d644df6bc40bedbfe2fd561359210c018929 /usr.bin/gzip
parentd2e0fb8db2bd08dedff42d79d6179b153aa934f1 (diff)
downloadFreeBSD-src-9a8b3cac780596343c946cecea69c661e3615e12.zip
FreeBSD-src-9a8b3cac780596343c946cecea69c661e3615e12.tar.gz
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
Diffstat (limited to 'usr.bin/gzip')
-rw-r--r--usr.bin/gzip/unpack.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/gzip/unpack.c b/usr.bin/gzip/unpack.c
index aa14800..cc717a6 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);
OpenPOWER on IntegriCloud