diff options
author | Xin LI <delphij@FreeBSD.org> | 2017-11-21 08:14:30 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2017-11-21 08:14:30 +0000 |
commit | 90f528e8d7868a5d31dc35b24943c673bf67821d (patch) | |
tree | 8cb4613b1f6062902779baf89fa3c4b69d6437f6 /usr.bin/gzip/unpack.c | |
parent | c0a0f12f9b7c596f08ab58fe4d42b7c75741da3e (diff) | |
download | src-90f528e8d7868a5d31dc35b24943c673bf67821d.tar.gz src-90f528e8d7868a5d31dc35b24943c673bf67821d.zip |
Support SIGINFO.
Obtained from: NetBSD
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=326052
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, |