Introduce and use _zip_buffer_skip function.
diff --git a/lib/zip_buffer.c b/lib/zip_buffer.c index 3d79b09..43864f9 100644 --- a/lib/zip_buffer.c +++ b/lib/zip_buffer.c
@@ -303,6 +303,17 @@ } +int +_zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length) { + zip_uint64_t offset = buffer->offset + length; + + if (offset < buffer->offset) { + buffer->ok = false; + return -1; + } + return _zip_buffer_set_offset(buffer, offset); +} + zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer) {
diff --git a/lib/zip_dirent.c b/lib/zip_dirent.c index f787e46..630b6a4 100644 --- a/lib/zip_dirent.c +++ b/lib/zip_dirent.c
@@ -484,7 +484,7 @@ else if (local) { /* From appnote.txt: This entry in the Local header MUST include BOTH original and compressed file size fields. */ - (void)_zip_buffer_get_64(ef_buffer); + (void)_zip_buffer_skip(ef_buffer, 8); /* error is caught by _zip_buffer_eof() call */ } if (zde->comp_size == ZIP_UINT32_MAX) zde->comp_size = _zip_buffer_get_64(ef_buffer);
diff --git a/lib/zipint.h b/lib/zipint.h index 86edcb3..40f75c4 100644 --- a/lib/zipint.h +++ b/lib/zipint.h
@@ -478,6 +478,7 @@ int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i); int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i); int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i); +int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length); int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset); zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer);