Skip to content

Commit

Permalink
Merge pull request #30 from bdwyertech/fix_dk_test
Browse files Browse the repository at this point in the history
Fix read_tar_magic to properly return an array when a file has less than 264 characters
  • Loading branch information
tas50 authored Aug 28, 2018
2 parents 77eb5b6 + 8446b32 commit cf4ca99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mixlib/archive/tar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def is_tar_archive?(io)

def read_tar_magic(io)
io.rewind
magic = io.read(512).bytes[257..264].pack("C*")
magic = Array(io.read(512).bytes[257..264]).pack("C*")
io.rewind
magic
end
Expand Down
7 changes: 7 additions & 0 deletions spec/mixlib/tar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@
expect(extractor.send(:is_tar_archive?, raw)).to eq(false)
end
end
context "invalid small file" do
let(:data) { "testdir/#{Array.new(11) { "\x00" }.join}smallfile" }
it "does not identify an invalid header in a small file" do
extractor = described_class.new(tgz_archive)
expect(extractor.send(:is_tar_archive?, raw)).to eq(false)
end
end
end

end

0 comments on commit cf4ca99

Please sign in to comment.