Hello community, here is the log from the commit of package rubygem-rubyzip for openSUSE:Factory checked in at 2017-04-11 09:32:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-rubyzip (Old) and /work/SRC/openSUSE:Factory/.rubygem-rubyzip.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-rubyzip" Tue Apr 11 09:32:18 2017 rev:12 rq:479190 version:1.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-rubyzip/rubygem-rubyzip.changes 2016-03-07 13:27:52.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-rubyzip.new/rubygem-rubyzip.changes 2017-04-11 09:32:19.301922664 +0200 @@ -1,0 +2,6 @@ +Thu Feb 9 05:58:07 UTC 2017 - coolo@suse.com + +- updated to version 1.2.1 + Fixes bsc#1027050 CVE-2017-5946 + +------------------------------------------------------------------- Old: ---- rubyzip-1.2.0.gem New: ---- rubyzip-1.2.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-rubyzip.spec ++++++ --- /var/tmp/diff_new_pack.QLVWgN/_old 2017-04-11 09:32:20.541747523 +0200 +++ /var/tmp/diff_new_pack.QLVWgN/_new 2017-04-11 09:32:20.545746958 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-rubyzip # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-rubyzip -Version: 1.2.0 +Version: 1.2.1 Release: 0 %define mod_name rubyzip %define mod_full_name %{mod_name}-%{version} ++++++ rubyzip-1.2.0.gem -> rubyzip-1.2.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-02-19 10:24:26.000000000 +0100 +++ new/README.md 2017-02-08 12:50:34.000000000 +0100 @@ -62,20 +62,18 @@ Copy from [here](https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac2... ) ```ruby -require 'rubygems' require 'zip' + # This is a simple example which uses rubyzip to # recursively generate a zip file from the contents of # a specified directory. The directory itself is not # included in the archive, rather just its contents. # # Usage: -# require /path/to/the/ZipFileGenerator/Class -# directoryToZip = "/tmp/input" -# outputFile = "/tmp/out.zip" -# zf = ZipFileGenerator.new(directoryToZip, outputFile) -# zf.write() - +# directory_to_zip = "/tmp/input" +# output_file = "/tmp/out.zip" +# zf = ZipFileGenerator.new(directory_to_zip, output_file) +# zf.write() class ZipFileGenerator # Initialize with the directory to zip and the location of the output archive. def initialize(input_dir, output_file) @@ -117,7 +115,7 @@ def put_into_archive(disk_file_path, io, zip_file_path) io.get_output_stream(zip_file_path) do |f| - f.puts(File.open(disk_file_path, 'rb').read) + f.write(File.open(disk_file_path, 'rb').read) end end end @@ -218,7 +216,7 @@ out.write rels.to_xml(:indent => 0).gsub("\n","") end -File.open(new_path, "w") {|f| f.write(buffer.string) } +File.open(new_path, "wb") {|f| f.write(buffer.string) } ``` ## Configuration Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zip/entry.rb new/lib/zip/entry.rb --- old/lib/zip/entry.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/lib/zip/entry.rb 2017-02-08 12:50:34.000000000 +0100 @@ -7,6 +7,7 @@ attr_accessor :comment, :compressed_size, :crc, :extra, :compression_method, :name, :size, :local_header_offset, :zipfile, :fstype, :external_file_attributes, + :internal_file_attributes, :gp_flags, :header_signature, :follow_symlinks, :restore_times, :restore_permissions, :restore_ownership, :unix_uid, :unix_gid, :unix_perms, @@ -149,6 +150,11 @@ def extract(dest_path = @name, &block) block ||= proc { ::Zip.on_exists_proc } + if @name.squeeze('/') =~ /.{2}(?:/|\z)/ + puts "WARNING: skipped "../" path component(s) in #{@name}" + return self + end + if directory? || file? || symlink? __send__("create_#{@ftype}", dest_path, &block) else @@ -357,7 +363,7 @@ unpack_c_dir_entry(static_sized_fields_buf) check_c_dir_entry_signature set_time(@last_mod_date, @last_mod_time) - @name = io.read(@name_length).tr('\', '/') + @name = io.read(@name_length) read_c_dir_extra_field(io) @comment = io.read(@comment_length) check_c_dir_entry_comment_size diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zip/entry_set.rb new/lib/zip/entry_set.rb --- old/lib/zip/entry_set.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/lib/zip/entry_set.rb 2017-02-08 12:50:34.000000000 +0100 @@ -57,7 +57,7 @@ @entry_set[to_key(entry.parent_as_string)] end - def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH) + def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB) entries.map do |entry| next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags) yield(entry) if block_given? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zip/file.rb new/lib/zip/file.rb --- old/lib/zip/file.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/lib/zip/file.rb 2017-02-08 12:50:34.000000000 +0100 @@ -43,7 +43,7 @@ # interface for accessing the filesystem, ie. the File and Dir classes. class File < CentralDirectory - CREATE = 1 + CREATE = true SPLIT_SIGNATURE = 0x08074b50 ZIP64_EOCD_SIGNATURE = 0x06064b50 MAX_SEGMENT_SIZE = 3_221_225_472 @@ -64,20 +64,19 @@ # Opens a zip archive. Pass true as the second parameter to create # a new archive if it doesn't exist already. - def initialize(file_name, create = nil, buffer = false, options = {}) + def initialize(file_name, create = false, buffer = false, options = {}) super() @name = file_name @comment = '' - @create = create + @create = create ? true : false # allow any truthy value to mean true case when !buffer && ::File.size?(file_name) - @create = nil + @create = false @file_permissions = ::File.stat(file_name).mode ::File.open(name, 'rb') do |f| read_from_stream(f) end - when create - @file_permissions = create_file_permissions + when @create @entry_set = EntrySet.new when ::File.zero?(file_name) raise Error, "File #{file_name} has zero size. Did you mean to pass the create flag?" @@ -95,7 +94,7 @@ # Same as #new. If a block is passed the ZipFile object is passed # to the block and is automatically closed afterwards just as with # ruby's builtin File.open method. - def open(file_name, create = nil) + def open(file_name, create = false) zf = ::Zip::File.new(file_name, create) return zf unless block_given? begin @@ -130,6 +129,7 @@ end zf = ::Zip::File.new(io, true, true, options) zf.read_from_stream(io) + return zf unless block_given? yield zf begin zf.write_buffer(io) @@ -340,7 +340,7 @@ @entry_set.each do |e| return true if e.dirty end - @comment != @stored_comment || @entry_set != @stored_entries || @create == ::Zip::File::CREATE + @comment != @stored_comment || @entry_set != @stored_entries || @create end # Searches for entry with the specified name. Returns nil if @@ -403,27 +403,18 @@ end def on_success_replace - tmp_filename = create_tmpname - if yield tmp_filename - ::File.rename(tmp_filename, name) - ::File.chmod(@file_permissions, name) if defined?(@file_permissions) - end - ensure - ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename) - end - - def create_tmpname dirname, basename = ::File.split(name) - ::Dir::Tmpname.create(basename, dirname) do |tmpname| - opts = {perm: 0600, mode: ::File::CREAT | ::File::WRONLY | ::File::EXCL} - f = File.open(tmpname, opts) - f.close + ::Dir::Tmpname.create(basename, dirname) do |tmp_filename| + begin + if yield tmp_filename + ::File.rename(tmp_filename, name) + ::File.chmod(@file_permissions, name) unless @create + end + ensure + ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename) + end end end - - def create_file_permissions - ::Zip::RUNNING_ON_WINDOWS ? 0644 : 0666 - ::File.umask - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zip/ioextras/abstract_output_stream.rb new/lib/zip/ioextras/abstract_output_stream.rb --- old/lib/zip/ioextras/abstract_output_stream.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/lib/zip/ioextras/abstract_output_stream.rb 2017-02-08 12:50:34.000000000 +0100 @@ -20,12 +20,12 @@ def putc(an_object) self << case an_object - when Fixnum + when Integer an_object.chr when String an_object else - raise TypeError, 'putc: Only Fixnum and String supported' + raise TypeError, 'putc: Only Integer and String supported' end an_object end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/zip/version.rb new/lib/zip/version.rb --- old/lib/zip/version.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/lib/zip/version.rb 2017-02-08 12:50:34.000000000 +0100 @@ -1,3 +1,3 @@ module Zip - VERSION = '1.2.0' + VERSION = '1.2.1' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-02-19 10:24:26.000000000 +0100 +++ new/metadata 2017-02-08 12:50:34.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: rubyzip version: !ruby/object:Gem::Version - version: 1.2.0 + version: 1.2.1 platform: ruby authors: - Alexander Simonov autorequire: bindir: bin cert_chain: [] -date: 2016-02-19 00:00:00.000000000 Z +date: 2017-02-08 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -197,7 +197,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.8 +rubygems_version: 2.5.1 signing_key: specification_version: 4 summary: rubyzip is a ruby module for reading and writing zip files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/samples/example_recursive.rb new/samples/example_recursive.rb --- old/samples/example_recursive.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/samples/example_recursive.rb 2017-02-08 12:50:34.000000000 +0100 @@ -6,7 +6,7 @@ # included in the archive, rather just its contents. # # Usage: -# directoryToZip = "/tmp/input" +# directory_to_zip = "/tmp/input" # output_file = "/tmp/out.zip" # zf = ZipFileGenerator.new(directory_to_zip, output_file) # zf.write() @@ -50,8 +50,6 @@ end def put_into_archive(disk_file_path, io, zip_file_path) - io.get_output_stream(zip_file_path) do |f| - f.write(File.open(disk_file_path, 'rb').read) - end + io.add(zip_file_path, disk_file_path) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/central_directory_entry_test.rb new/test/central_directory_entry_test.rb --- old/test/central_directory_entry_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/central_directory_entry_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -37,7 +37,7 @@ assert_equal('', entry.comment) entry = ::Zip::Entry.read_c_dir_entry(file) - assert_equal(nil, entry) + assert_nil(entry) # Fields that are not check by this test: # version made by 2 bytes # version needed to extract 2 bytes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/crypto/null_encryption_test.rb new/test/crypto/null_encryption_test.rb --- old/test/crypto/null_encryption_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/crypto/null_encryption_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -18,7 +18,9 @@ end def test_encrypt - [nil, '', 'a' * 10, 0xffffffff].each do |data| + assert_nil @encrypter.encrypt(nil) + + ['', 'a' * 10, 0xffffffff].each do |data| assert_equal data, @encrypter.encrypt(data) end end @@ -42,7 +44,9 @@ end def test_decrypt - [nil, '', 'a' * 10, 0xffffffff].each do |data| + assert_nil @decrypter.decrypt(nil) + + ['', 'a' * 10, 0xffffffff].each do |data| assert_equal data, @decrypter.decrypt(data) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/entry_set_test.rb new/test/entry_set_test.rb --- old/test/entry_set_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/entry_set_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -76,7 +76,7 @@ ::Zip.case_insensitive_match = false zipEntrySet = ::Zip::EntrySet.new(entries) assert_equal(entries[0], zipEntrySet.find_entry('MiXeDcAsEnAmE')) - assert_equal(nil, zipEntrySet.find_entry('mixedcasename')) + assert_nil(zipEntrySet.find_entry('mixedcasename')) end def test_entries_with_sort @@ -123,7 +123,7 @@ ] entrySet = ::Zip::EntrySet.new(entries) - assert_equal(nil, entrySet.parent(entries[0])) + assert_nil(entrySet.parent(entries[0])) assert_equal(entries[0], entrySet.parent(entries[1])) assert_equal(entries[1], entrySet.parent(entries[2])) end @@ -149,4 +149,15 @@ # assert_equal(entries.size, res.size) # assert_equal(entrySet.map { |e| e.name }, res.map { |e| e.name }) end + + def test_glob3 + entries = [ + ::Zip::Entry.new('zf.zip', 'a/a'), + ::Zip::Entry.new('zf.zip', 'a/b'), + ::Zip::Entry.new('zf.zip', 'a/c') + ] + entrySet = ::Zip::EntrySet.new(entries) + + assert_equal(entries[0, 2].sort, entrySet.glob('a/{a,b}').sort) + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/entry_test.rb new/test/entry_test.rb --- old/test/entry_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/entry_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -1,16 +1,7 @@ require 'test_helper' class ZipEntryTest < MiniTest::Test - TEST_ZIPFILE = 'someZipFile.zip' - TEST_COMMENT = 'a comment' - TEST_COMPRESSED_SIZE = 1234 - TEST_CRC = 325_324 - TEST_EXTRA = 'Some data here' - TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED - TEST_NAME = 'entry name' - TEST_SIZE = 8432 - TEST_ISDIRECTORY = false - TEST_TIME = Time.now + include ZipEntryData def test_constructor_and_getters entry = ::Zip::Entry.new(TEST_ZIPFILE, @@ -118,8 +109,8 @@ entry5 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc') entry6 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc/') - assert_equal(nil, entry1.parent_as_string) - assert_equal(nil, entry2.parent_as_string) + assert_nil(entry1.parent_as_string) + assert_nil(entry2.parent_as_string) assert_equal('aa/', entry3.parent_as_string) assert_equal('aa/', entry4.parent_as_string) assert_equal('aa/bb/', entry5.parent_as_string) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/file_permissions_test.rb new/test/file_permissions_test.rb --- old/test/file_permissions_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/file_permissions_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -2,58 +2,58 @@ class FilePermissionsTest < MiniTest::Test - FILENAME = File.join(File.dirname(__FILE__), "umask.zip") + ZIPNAME = File.join(File.dirname(__FILE__), "umask.zip") + FILENAME = File.join(File.dirname(__FILE__), "umask.txt") def teardown + ::File.unlink(ZIPNAME) ::File.unlink(FILENAME) end - if ::Zip::RUNNING_ON_WINDOWS - # Windows tests - - DEFAULT_PERMS = 0644 - - def test_windows_perms - create_file + def test_current_umask + create_files + assert_matching_permissions FILENAME, ZIPNAME + end - assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode + def test_umask_000 + set_umask(0000) do + create_files end - else - # Unix tests - - DEFAULT_PERMS = 0100666 - - def test_current_umask - umask = DEFAULT_PERMS - ::File.umask - create_file + assert_matching_permissions FILENAME, ZIPNAME + end - assert_equal umask, ::File.stat(FILENAME).mode + def test_umask_066 + set_umask(0066) do + create_files end - def test_umask_000 - set_umask(0000) do - create_file - end + assert_matching_permissions FILENAME, ZIPNAME + end - assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode + def test_umask_027 + set_umask(0027) do + create_files end - def test_umask_066 - umask = 0066 - set_umask(umask) do - create_file - end - - assert_equal((DEFAULT_PERMS - umask), ::File.stat(FILENAME).mode) - end + assert_matching_permissions FILENAME, ZIPNAME + end + def assert_matching_permissions(expected_file, actual_file) + assert_equal( + ::File.stat(expected_file).mode.to_s(8).rjust(4, '0'), + ::File.stat(actual_file).mode.to_s(8).rjust(4, '0') + ) end - def create_file - ::Zip::File.open(FILENAME, ::Zip::File::CREATE) do |zip| + def create_files + ::Zip::File.open(ZIPNAME, ::Zip::File::CREATE) do |zip| zip.comment = "test" end + + ::File.open(FILENAME, 'w') do |file| + file << 'test' + end end # If anything goes wrong, make sure the umask is restored. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/file_test.rb new/test/file_test.rb --- old/test/file_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/file_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -2,6 +2,7 @@ class ZipFileTest < MiniTest::Test include CommonZipFileFixture + include ZipEntryData OK_DELETE_FILE = 'test/data/generated/okToDelete.txt' OK_DELETE_MOVED_FILE = 'test/data/generated/okToDeleteMoved.txt' @@ -40,6 +41,20 @@ assert_equal(2, zfRead.entries.length) end + def test_create_from_scratch_with_old_create_parameter + comment = 'a short comment' + + zf = ::Zip::File.new(EMPTY_FILENAME, 1) + zf.get_output_stream('myFile') { |os| os.write 'myFile contains just this' } + zf.mkdir('dir1') + zf.comment = comment + zf.close + + zfRead = ::Zip::File.new(EMPTY_FILENAME) + assert_equal(comment, zfRead.comment) + assert_equal(2, zfRead.entries.length) + end + def test_get_output_stream entryCount = nil ::Zip::File.open(TEST_ZIP.zip_name) do |zf| @@ -56,7 +71,7 @@ assert_equal(entryCount + 1, zf.size) assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt')) - custom_entry_args = [ZipEntryTest::TEST_COMMENT, ZipEntryTest::TEST_EXTRA, ZipEntryTest::TEST_COMPRESSED_SIZE, ZipEntryTest::TEST_CRC, ::Zip::Entry::STORED, ZipEntryTest::TEST_SIZE, ZipEntryTest::TEST_TIME] + custom_entry_args = [TEST_COMMENT, TEST_EXTRA, TEST_COMPRESSED_SIZE, TEST_CRC, ::Zip::Entry::STORED, TEST_SIZE, TEST_TIME] zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) do |os| os.write 'Some data' end @@ -89,6 +104,12 @@ end end + def test_open_buffer_without_block + string_io = StringIO.new File.read('test/data/rubycode.zip') + zf = ::Zip::File.open_buffer string_io + assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb') + end + def test_cleans_up_tempfiles_after_close zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE) zf.get_output_stream('myFile') do |os| @@ -528,9 +549,8 @@ end def test_empty_zip - puts `touch empty.zip` assert_raises(::Zip::Error) do - ::Zip::File.open('empty.zip') + ::Zip::File.open(TestFiles::NULL_FILE) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/filesystem/file_nonmutating_test.rb new/test/filesystem/file_nonmutating_test.rb --- old/test/filesystem/file_nonmutating_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/filesystem/file_nonmutating_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -103,12 +103,12 @@ end def test_size? - assert_equal(nil, @zip_file.file.size?('notAFile')) + assert_nil(@zip_file.file.size?('notAFile')) assert_equal(72, @zip_file.file.size?('file1')) - assert_equal(nil, @zip_file.file.size?('dir2/dir21')) + assert_nil(@zip_file.file.size?('dir2/dir21')) assert_equal(72, @zip_file.file.stat('file1').size?) - assert_equal(nil, @zip_file.file.stat('dir2/dir21').size?) + assert_nil(@zip_file.file.stat('dir2/dir21').size?) end def test_file? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/filesystem/file_stat_test.rb new/test/filesystem/file_stat_test.rb --- old/test/filesystem/file_stat_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/filesystem/file_stat_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -11,7 +11,7 @@ end def test_blocks - assert_equal(nil, @zip_file.file.stat('file1').blocks) + assert_nil(@zip_file.file.stat('file1').blocks) end def test_ino diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/gentestfiles.rb new/test/gentestfiles.rb --- old/test/gentestfiles.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/gentestfiles.rb 2017-02-08 12:50:34.000000000 +0100 @@ -9,6 +9,8 @@ RANDOM_BINARY_FILE1 = 'test/data/generated/randomBinary1.bin' RANDOM_BINARY_FILE2 = 'test/data/generated/randomBinary2.bin' + NULL_FILE = 'test/data/generated/null.zip' # Zero length, so not a zip file. + EMPTY_TEST_DIR = 'test/data/generated/emptytestdir' ASCII_TEST_FILES = [RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3] @@ -28,6 +30,8 @@ create_random_binary(filename, 1E4 * (index + 1)) end + system("touch #{NULL_FILE}") + ensure_dir(EMPTY_TEST_DIR) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/input_stream_test.rb new/test/input_stream_test.rb --- old/test/input_stream_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/input_stream_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -75,12 +75,12 @@ entry = zis.get_next_entry # empty.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name) assert_equal(0, entry.size) - assert_equal(nil, zis.gets) + assert_nil(zis.gets) assert_equal(true, zis.eof?) entry = zis.get_next_entry # empty_chmod640.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[2], entry.name) assert_equal(0, entry.size) - assert_equal(nil, zis.gets) + assert_nil(zis.gets) assert_equal(true, zis.eof?) entry = zis.get_next_entry # short.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name) @@ -102,12 +102,12 @@ entry = zis.get_next_entry # empty.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name) assert_equal(0, entry.size) - assert_equal(nil, zis.gets) + assert_nil(zis.gets) assert_equal(true, zis.eof?) entry = zis.get_next_entry # empty_chmod640.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[2], entry.name) assert_equal(0, entry.size) - assert_equal(nil, zis.gets) + assert_nil(zis.gets) assert_equal(true, zis.eof?) entry = zis.get_next_entry # short.txt assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/ioextras/abstract_input_stream_test.rb new/test/ioextras/abstract_input_stream_test.rb --- old/test/ioextras/abstract_input_stream_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/ioextras/abstract_input_stream_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -44,7 +44,7 @@ assert_equal(2, @io.lineno) assert_equal(TEST_LINES[2], @io.gets) assert_equal(3, @io.lineno) - assert_equal(nil, @io.gets) + assert_nil(@io.gets) assert_equal(4, @io.lineno) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/ioextras/fake_io_test.rb new/test/ioextras/fake_io_test.rb --- old/test/ioextras/fake_io_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/ioextras/fake_io_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -12,7 +12,7 @@ assert(obj.kind_of?(Object)) assert(obj.kind_of?(FakeIOUsingClass)) assert(obj.kind_of?(IO)) - assert(!obj.kind_of?(Fixnum)) + assert(!obj.kind_of?(Integer)) assert(!obj.kind_of?(String)) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/local_entry_test.rb new/test/local_entry_test.rb --- old/test/local_entry_test.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/local_entry_test.rb 2017-02-08 12:50:34.000000000 +0100 @@ -36,7 +36,7 @@ def test_read_local_entry_from_non_zip_file ::File.open('test/data/file2.txt') do |file| - assert_equal(nil, ::Zip::Entry.read_local_entry(file)) + assert_nil(::Zip::Entry.read_local_entry(file)) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb --- old/test/test_helper.rb 2016-02-19 10:24:26.000000000 +0100 +++ new/test/test_helper.rb 2017-02-08 12:50:34.000000000 +0100 @@ -134,7 +134,7 @@ testZipFile.entry_names.each do |entryName| assert_next_entry(entryName, zis) end - assert_equal(nil, zis.get_next_entry) + assert_nil(zis.get_next_entry) end def assert_test_zip_contents(testZipFile) @@ -219,3 +219,16 @@ anObject.instance_eval "undef #{method}; alias #{method} #{method}_org" end end + +module ZipEntryData + TEST_ZIPFILE = 'someZipFile.zip' + TEST_COMMENT = 'a comment' + TEST_COMPRESSED_SIZE = 1234 + TEST_CRC = 325_324 + TEST_EXTRA = 'Some data here' + TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED + TEST_NAME = 'entry name' + TEST_SIZE = 8432 + TEST_ISDIRECTORY = false + TEST_TIME = Time.now +end