zlib-ng / minizip-ng

Fork of the popular zip manipulation library found in the zlib distribution.
Other
1.24k stars 434 forks source link

mz_zip_entry_write_open use of file_info, modified after writing #828

Closed rombust closed 1 week ago

rombust commented 1 week ago

Looking at the function: mz_zip_entry_write_open

zip->file_info is copied near the start of the function

       memcpy(&zip->file_info, file_info, sizeof(mz_zip_file));
       mz_stream_write(zip->file_info_stream, file_info, sizeof(mz_zip_file));

But zip->file_info maybe modified later on


  if (!is_dir) {
        if (zip->data_descriptor)
            zip->file_info.flag |= MZ_ZIP_FLAG_DATA_DESCRIPTOR;
        if (password)
            zip->file_info.flag |= MZ_ZIP_FLAG_ENCRYPTED;
    }

Those familiar with the code base, is this okay ? I am unsure at the moment if file_info_stream requires these flags to match those pushed to mz_zip_entry_write_header?

nmoinvaz commented 1 week ago

Those two flags have alternative methods of configuration.

rombust commented 1 week ago

Thanks. I can see that now.