libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit d9d073c66b49b91403484e081eda39d4e5c17cc2
parent f792c47a04c55c82f7ed66c727ebe96ccc99a473
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 15 Oct 2017 20:46:58 +0200

fix signed/unsigned comparison issue

Diffstat:
Msrc/main/extractor_datasource.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c @@ -462,6 +462,7 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs, { unsigned int gzip_header_length = 10; unsigned char hdata[12]; + ssize_t rsize; if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET)) { @@ -469,7 +470,9 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs, return -1; } /* Process gzip header */ - if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata))) + rsize = bfds_read (cfs->bfds, hdata, sizeof (hdata)); + if ( (-1 == rsize) || + (sizeof (hdata) > (size_t) rsize) ) return -1; if (0 != (hdata[3] & 0x4)) /* FEXTRA set */ gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);