kuba-- / zip

A portable, simple zip library written in C
MIT License
1.43k stars 275 forks source link

Runtime error on creating archive #112

Closed maxsupermanhd closed 4 years ago

maxsupermanhd commented 4 years ago
lib/miniz.h:4630:15: runtime error: load of misaligned address 0x7fff23b7d17b for type 'const mz_uint32', which requires 4 byte alignment
0x7fff23b7d17b: note: pointer points here
 03  00 00 e5 4b 01 00 00 00  00 00 00 00 00 00 00 00  00 8d c9 2e b8 68 20 11  d0 d1 b7 23 ff 7f 00
              ^ 
maxsupermanhd commented 4 years ago

IDK how i get this and how it works but it cant open archive 8c-Sk-mischief-17555125ef4ff968085a43d616f21d6d3247872a9b9dda350fc5e4a1894e844d.zip

kuba-- commented 4 years ago

Thanks, I'll take a look closer. Maybe it's because of following extra info in central directory (64bit is not supported, yet):

 The central-directory extra field contains:
  - A subfield with ID 0x0001 (PKWARE 64-bit sizes) and 16 data bytes:
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00.
maxsupermanhd commented 4 years ago

Oh, that's kinda 64 bit zip maybe... Well I'm waiting 64 bit support.

kuba-- commented 4 years ago

Yeah, you're not the first one ;) I have to put some effort and finally add it (what can be very tricky and fragile). Anyway, for this particular case, it's just my first thought. I'll have to take a look closer. Maybe it's not really 64bit zip, but it just contains some 64bit flags which we can ignore.

kuba-- commented 4 years ago

@maxsupermanhd - is it Windows' issue? Because, I tested (on master branch) on OSX and everything looks fine (I was able to open and extract your archive).

kuba-- commented 4 years ago

@maxsupermanhd - could you verify, it's a windows issue? I don't have locally windows machine, so it could be helpful.

maxsupermanhd commented 4 years ago

I didn't tried that on windows yet. Seems to be only Linux issue...

kuba-- commented 4 years ago

@maxsupermanhd - I tried to reproduce it on the latest ubuntu Linux 94e507b7ce89 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux with gcc (Ubuntu 9.2.1-21ubuntu1) 9.2.1 20191130 but I successfully extracted 10 entries:

Extracted: /tmp/8c-mischief.addon.lev (1)
Extracted: /tmp/multiplay/ (2)
Extracted: /tmp/multiplay/maps/ (3)
Extracted: /tmp/multiplay/maps/8c-mischief/ (4)
Extracted: /tmp/multiplay/maps/8c-mischief.gam (5)
Extracted: /tmp/multiplay/maps/8c-mischief/dinit.bjo (6)
Extracted: /tmp/multiplay/maps/8c-mischief/feat.bjo (7)
Extracted: /tmp/multiplay/maps/8c-mischief/game.map (8)
Extracted: /tmp/multiplay/maps/8c-mischief/struct.bjo (9)
Extracted: /tmp/multiplay/maps/8c-mischief/ttypes.ttp (10)

with following snippet:

#include <stdio.h>
#include "zip.h"

int on_extract_entry(const char *filename, void *arg) {
    static int i = 0;
    printf("Extracted: %s (%d)\n", filename, ++i);

    return 0;
}

int main() {
    return zip_extract("/tmp/test.zip", "/tmp", on_extract_entry, NULL);
}
maxsupermanhd commented 4 years ago

Yeah, it works fine but in some situations its failing without context. Kinda strange bug and i cant actually figure out where it goes... I've somehow fixed this in by source or its just too tricky to reproduce. For now this issue can be closed. I'll reopen if needed.