diff options
Diffstat (limited to 'usr.bin/gzip/unpack.c')
-rw-r--r-- | usr.bin/gzip/unpack.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr.bin/gzip/unpack.c b/usr.bin/gzip/unpack.c index afab9ed64aa2..f07cae0945c2 100644 --- a/usr.bin/gzip/unpack.c +++ b/usr.bin/gzip/unpack.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $NetBSD: unpack.c,v 1.3 2017/08/04 07:27:08 mrg Exp $ */ + /*- * Copyright (c) 2009 Xin LI <delphij@FreeBSD.org> * All rights reserved. @@ -152,6 +155,9 @@ unpack_parse_header(int in, int out, char *pre, size_t prelen, off_t *bytes_in, ssize_t bytesread; /* Bytes read from the file */ int i, j, thisbyte; + if (prelen > sizeof hdr) + maybe_err("prelen too long"); + /* Prepend the header buffer if we already read some data */ if (prelen != 0) memcpy(hdr, pre, prelen); @@ -160,6 +166,7 @@ unpack_parse_header(int in, int out, char *pre, size_t prelen, off_t *bytes_in, bytesread = read(in, hdr + prelen, PACK_HEADER_LENGTH - prelen); if (bytesread < 0) maybe_err("Error reading pack header"); + infile_newdata(bytesread); accepted_bytes(bytes_in, PACK_HEADER_LENGTH); @@ -206,6 +213,7 @@ unpack_parse_header(int in, int out, char *pre, size_t prelen, off_t *bytes_in, accepted_bytes(bytes_in, unpackd->treelevels); if (unpackd->symbol_size > 256) maybe_errx("Bad symbol table"); + infile_newdata(unpackd->treelevels); /* Allocate for the symbol table, point symbol_eob at the beginning */ unpackd->symbol_eob = unpackd->symbol = calloc(1, unpackd->symbol_size); @@ -229,6 +237,7 @@ unpack_parse_header(int in, int out, char *pre, size_t prelen, off_t *bytes_in, maybe_errx("Symbol table truncated"); *unpackd->symbol_eob++ = (char)thisbyte; } + infile_newdata(unpackd->symbolsin[i]); accepted_bytes(bytes_in, unpackd->symbolsin[i]); } @@ -266,6 +275,8 @@ unpack_decode(const unpack_descriptor_t *unpackd, off_t *bytes_in) while ((thisbyte = fgetc(unpackd->fpIn)) != EOF) { accepted_bytes(bytes_in, 1); + infile_newdata(1); + check_siginfo(); /* * Split one bit from thisbyte, from highest to lowest, |