When looking up the compression name for a zip file the index variable was being
incremented too soon. Thus element zero ("uncompressed") was never checked and
reads could be made past the end of the array. This was causing intermittent
segfaults in the call to sprintf in zip_read_local_file_header.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
{
static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]);
int i=0;
- while(compression >= 0 && i++ < num_compression_methods) {
+ while(compression >= 0 && i < num_compression_methods) {
if (compression_methods[i].id == compression) {
return compression_methods[i].name;
}
+ i++;
}
return "??";
}