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

RubyZip doesn't work well after updating zlib to v.1.2.12 #623

Closed
jiu3bao3 opened this issue Apr 2, 2022 · 6 comments
Closed

RubyZip doesn't work well after updating zlib to v.1.2.12 #623

jiu3bao3 opened this issue Apr 2, 2022 · 6 comments

Comments

@jiu3bao3
Copy link

jiu3bao3 commented Apr 2, 2022

I have updated zlib from 1.2.11 to 1.2.12. After this updating, RubyZip doesn't work well, The following code generates a zip file includeing a empty file named test.txt. In the environment using older version of zlib, the following code generates a zip file including a text file containing the text of "Hello World!"

Ruby Version: 3.1

require 'zip'
require 'zlib'

Zip::OutputStream.open("test.zip", Zip::TraditionalEncrypter.new("password")) do |zip|
    zip.put_next_entry("test.txt")
    zip.print("Hello World!\n")
end
@madler
Copy link
Owner

madler commented Oct 6, 2022

You'd need to be more explicit about "doesn't work well". You say what happens with 1.2.11, but nothing about what happens with 1.2.12.

@jiu3bao3
Copy link
Author

jiu3bao3 commented Oct 6, 2022

The phenomenon I've said "doesn't work well' is following.

Before updating zlib1.2.12 , contents of output file 'test.txt' was like following.

Hello World!\n

But after updating zlib to version 1.2.12, contents of output file 'test.txt' was empty(0 byte). Nothing was written in output file.

@madler
Copy link
Owner

madler commented Oct 6, 2022

test.txt is not the output file. test.zip is the output file of your example code. Do you mean that test.zip contains an entry named test.txt, but if you unzip it, the resulting file is empty?

@jiu3bao3
Copy link
Author

jiu3bao3 commented Oct 7, 2022

Sorry, Zip entry 'test.txt' seems to be empty, but just extracting contents of zip failed. I tried to unzip using another unzip tool. which says 'Incorrect Password'.

I ran the program again. Output file named "test.zip" contains a entry named "test.txt". but the password validation failed and could not extract contents of zip entry. I ran the program using different password and tried to extract contents, but I cannot extract a content in the zip file.

irb(main):001:0> require 'zip'
=> true
irb(main):002:1* Zip::OutputStream.open("test.zip", Zip::TraditionalEncrypter.ne
irb(main):002:1* Zip::OutputStream.open("test.zip", Zip::TraditionalEncrypter.ne
w("password")) do |zip|
irb(main):003:1*   zip.put_next_entry("test.txt")
irb(main):004:1*   zip.print("Hello World!\n")
irb(main):005:0> end
=>
#<Zip::OutputStream:0x00007f654ac81d18
 @closed=true,
 @comment=nil,
 @compressor=#<Zip::NullCompressor:0x00007f654ac819f8>,
 @current_entry=nil,
 @encrypter=
  #<Zip::TraditionalEncrypter:0x00007f654ac82290
   @key0=-3078641201,
   @key1=233305526,
   @key2=-3625664778,
   @password="password">,
 @entry_set=
  #<Zip::EntrySet:0x00007f654ac81b60
   @entry_set=
    {"test.txt"=>
      #<Zip::Entry:0x00007f654ac81818
       @comment="",
       @compressed_size=27,
       @compression_method=8,
       @crc=2098519517,
       @dirty=false,
       @external_file_attributes=2175008768,
       @extra={},
       @filepath=nil,
       @follow_symlinks=false,
       @fstype=3,
       @ftype=:file,
       @gp_flags=9,
       @header_signature=33639248,
       @internal_file_attributes=1,
       @local_header_offset=0,
       @local_header_size=38,
       @name="test.txt",
       @restore_ownership=false,
       @restore_permissions=false,
       @restore_times=false,
       @size=13,
       @time=2022-10-07 09:34:43.140955641 +0900,
       @unix_gid=nil,
       @unix_perms=420,
       @unix_uid=nil,
       @version=52,
       @version_needed_to_extract=20,
       @zipfile="test.zip">}>,
 @file_name="test.zip",
 @output_stream=#<File:test.zip (closed)>>
irb(main):006:0> exit
[root@****** ~]# unzip test.zip
Archive:  test.zip
[test.zip] test.txt password:
password incorrect--reenter:
password incorrect--reenter:
   skipping: test.txt                incorrect password

@madler
Copy link
Owner

madler commented Oct 12, 2022

I'd need to know more about how exactly the new version was integrated with Ruby, but instead of that, please text the next release and report back here if there still is or is not an issue. Thanks.

@jiu3bao3
Copy link
Author

v.1.2.13 solved this issue. It works well. Thank you very much.

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

2 participants