Menu

#29 Trailing garbage in name is not ignored

open
nobody
None
5
2012-07-18
2008-12-19
John Allsup
No

If the name stored in a zip file is of the form

'hello\0 world'

most C string routines will ignore the ' world' at the end.
In the case of a zip file where the stored filename contains a null
character, most zip programs (on the mac) ignore the trailing garbage and consider the end of the name to be the null character. Rubyzip does not, and this causes a few headaches with some zip files (possibly generated by bad zip generating programs.)

Changing

@name = io.read(nameLength)

@name = io.read(nameLength).unpack('Z*').first

at line approx. 600 in zip.rb yields a behaviour that is reasonable and consistent with other .zip programs, with the name stored in the ZipEntry terminating at the first null character in the string read from the file.

Possibly a warning could be printed when RubyZip detects this, and then the trailing garbage ignored.

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.