gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
60 stars 50 forks source link

Fix incompatible pointer error #141

Closed nvinson closed 5 months ago

nvinson commented 1 year ago

Fixes gdraheim/zziplib#140

Signed-off-by: Nicholas Vinson nvinson234@gmail.com

tstellar commented 1 year ago

Is there anything preventing this patch from being merged?

fweimer-rh commented 7 months ago

I can't comment on this properly due to github/roadmap#347.

The full code fragment looks like this:

    ___ /* a ZIP64 extended block may follow. */
    size_t csize = zzip_file_header_csize(header);
    off_t offset = zzip_file_header_to_data(header);
    if (csize == 0xFFFFu) {
        struct zzip_extra_zip64* zip64 =
           zzip_file_header_to_extras(header);
        if (ZZIP_EXTRA_ZIP64_CHECK(zip64)) {
            csize = zzip_extra_zip64_csize(zip64);
        }
    }
    if (offset == 0xFFFFu) {
        struct zzip_extra_zip64* zip64 =
           zzip_file_header_to_extras(header);
        if (ZZIP_EXTRA_ZIP64_CHECK(zip64)) {
            offset = zzip_extra_zip64_offset(zip64);
        }
    }
…
    file->zlib.next_in = offset;

This looks like a real bug to me: As a de-facto pointer comparison, offset == 0xFFFFu can never be true. If there is a ZIP64 header, offset is never adjusted, so the decompression starts at the wrong offset. I suspect the offset adjustment needs to be moved under the csize check, and the second if statement should be deleted. The offset variable should a pointer, considering how it is used in the end.

gdraheim commented 5 months ago

Calling ot offset was wrong from the start - I implemented a different approach on develop

fweimer-rh commented 5 months ago

Calling ot offset was wrong from the start - I implemented a different approach on develop

@gdraheim Thanks. Is this commit bf539bd6a434f56f7ad7685fc0bc8496f652b5e8?