Failed to decompress gz file which has multi-header
- Dominant language
- C
- Stars
- 1.1k
- Forks
- 346
- PR merge metrics
- No merged PRs in 30d
Description

add line 9 to 15 in decompress_file function in igzip_cli.c, the bug fixed
1. while (state.avail_in > 0 && state.next_in[0] == 31)
2. {
3. // Look for magic numbers for gzip header. Follows the gzread() decision
4. // whether to treat as trailing junk
5. if (state.avail_in > 1 && state.next_in[1] != 139)
6. break;
7.
8. isal_inflate_reset(&state);
9. ret = isal_read_gzip_header(&state, &gz_hdr);
10. if (ret != ISAL_DECOMP_OK)
11. {
12. log_print(ERROR, "igzip: Error invalid gzip header found for file %s\n",
13. infile_name);
14. goto decompress_file_cleanup;
15. }
16.
17. state.crc_flag = ISAL_GZIP; // Let isal_inflate() process extra headers
18. do
19. {
20. if (state.avail_in == 0 && !feof(in))
21. {
22. state.next_in = inbuf;
23. state.avail_in =
24. fread_safe(state.next_in, 1, inbuf_size, in, infile_name);
25. }
26.
27. state.next_out = outbuf;
28. state.avail_out = outbuf_size;
29.
30. ret = isal_inflate(&state);
31. if (ret != ISAL_DECOMP_OK)
32. {
33. log_print(ERROR,
34. "igzip: Error while decompressing extra concatenated"
35. "gzip files on %s\n",
36. infile_name);
37. goto decompress_file_cleanup;
38. }
39.
40. if (out != NULL)
41. fwrite_safe(outbuf, 1, state.next_out - outbuf, out,
42. outfile_name);
43.
44. } while (state.block_state != ISAL_BLOCK_FINISH && (!feof(in) || state.avail_out == 0));
45.
46. if (!feof(in) && state.avail_in == 0)
47. {
48. state.next_in = inbuf;
49. state.avail_in =
50. fread_safe(state.next_in, 1, inbuf_size, in, infile_name);
51. }
52. }
53.
Contributor guide
Assessment
This issue has not been assessed yet.