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

a bug when read extra field gzip compressed data #8933

Open
orangeSi opened this issue Mar 24, 2020 · 1 comment · May be fixed by #14550
Open

a bug when read extra field gzip compressed data #8933

orangeSi opened this issue Mar 24, 2020 · 1 comment · May be fixed by #14550

Comments

@orangeSi
Copy link
Contributor

Submitting questions

hello everyone, when I read a gz file, I got error:

$echo -n 'H4sIBAAAAAAA/wYAQkMCADIAS0ksTuNKSyxO4UqtSC4pSuQqLilNS+MCAI56o3cXAAAAH4sIBAAAAAAA/wYAQkMCABsAAwAAAAAAAAAAAA==' | base64 -d > gggg2.gz

$ zcat gggg2.gz
dasf
fasd
exctra
stuff

$file gggg2.gz
gggg2.gz: gzip compressed data, extra field

$gzip -dc gggg2.gz |gzip >gggg3.gz

$file gggg3.gz
gggg3.gz: gzip compressed data, last modified: Tue Mar 24 02:15:48 2020, from Unix

and my demo code demo.cr is this:

require "gzip"


file=ARGV[0]
puts "input is #{file}"
Gzip::Reader.open(file) do |gfile|
	gfile.each_line do |line|
		puts line
	end
end

then test the demo code and data by this:

$crystal build demo.cr

$./demo gggg3.gz
input is gggg3.gz
dasf
fasd
exctra
stuff

$./demo gggg2.gz 
input is gggg2.gz
Unhandled exception: flate: invalid stored block lengths (Flate::Error)
  from /usr/share/crystal/src/flate/reader.cr:112:13 in 'unbuffered_read'
  from /usr/share/crystal/src/io/buffered.cr:79:16 in 'read'
  from /usr/share/crystal/src/gzip/reader.cr:90:7 in 'unbuffered_read'
  from /usr/share/crystal/src/io/buffered.cr:214:12 in 'fill_buffer'
  from /usr/share/crystal/src/io/buffered.cr:102:7 in 'peek'
  from /usr/share/crystal/src/io.cr:632:37 in 'gets'
  from /usr/share/crystal/src/io.cr:605:5 in 'gets'
  from /usr/share/crystal/src/io.cr:575:5 in 'gets'
  from /usr/share/crystal/src/io.cr:574:3 in 'gets'
  from /usr/share/crystal/src/io.cr:918:18 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:106:5 in 'main_user_code'
  from /usr/share/crystal/src/crystal/main.cr:92:7 in 'main'
  from /usr/share/crystal/src/crystal/main.cr:115:3 in 'main'
  from __libc_start_main
  from _start
  from ???


$cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"

$crystal --version
Crystal 0.33.0 [612825a53] (2020-02-14)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu

Thanks~

@orangeSi orangeSi changed the title Error when read extra field gzip compressed data bug when read extra field gzip compressed data Mar 24, 2020
@orangeSi orangeSi changed the title bug when read extra field gzip compressed data a bug when read extra field gzip compressed data Mar 24, 2020
@straight-shoota
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants