Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to decompress gz file which has multi-header #274

Open
wangruona opened this issue Jan 24, 2024 · 0 comments
Open

Failed to decompress gz file which has multi-header #274

wangruona opened this issue Jan 24, 2024 · 0 comments

Comments

@wangruona
Copy link

image

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. isal_inflate_reset(&state);
  8. ret = isal_read_gzip_header(&state, &gz_hdr);
  9. if (ret != ISAL_DECOMP_OK)
  10. {
  11. log_print(ERROR, "igzip: Error invalid gzip header found for file %s\n",
  12. infile_name);
  13. goto decompress_file_cleanup;
  14. }
  15. state.crc_flag = ISAL_GZIP; // Let isal_inflate() process extra headers
  16. do
  17. {
  18. if (state.avail_in == 0 && !feof(in))
  19. {
  20. state.next_in = inbuf;
  21. state.avail_in =
  22. fread_safe(state.next_in, 1, inbuf_size, in, infile_name);
  23. }
  24. state.next_out = outbuf;
  25. state.avail_out = outbuf_size;
  26. ret = isal_inflate(&state);
  27. if (ret != ISAL_DECOMP_OK)
  28. {
  29. log_print(ERROR,
  30. "igzip: Error while decompressing extra concatenated"
  31. "gzip files on %s\n",
  32. infile_name);
  33. goto decompress_file_cleanup;
  34. }
  35. if (out != NULL)
  36. fwrite_safe(outbuf, 1, state.next_out - outbuf, out,
  37. outfile_name);
  38. } while (state.block_state != ISAL_BLOCK_FINISH && (!feof(in) || state.avail_out == 0));
  39. if (!feof(in) && state.avail_in == 0)
  40. {
  41. state.next_in = inbuf;
  42. state.avail_in =
  43. fread_safe(state.next_in, 1, inbuf_size, in, infile_name);
  44. }
  45. }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant