File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ function git_file_hash(
170170 while size > 0
171171 n = min (t, length (buf))
172172 r = readbytes! (tar, buf, n)
173- r < n && eof (io ) && error ( " premature end of tar file " )
173+ r < n && eof (tar ) && throw ( EOFError () )
174174 v = view (buf, 1 : min (r, size))
175175 SHA. update! (ctx, v)
176176 size -= length (v)
Original file line number Diff line number Diff line change 8484 rm (tarball)
8585end
8686
87+ @testset " truncated tarball" begin
88+ tarball, hash = make_test_tarball ()
89+ open (tarball, " a" ) do io
90+ truncate (io, div (filesize (tarball),2 ))
91+ end
92+
93+ @testset " tree_hash" begin
94+ # Ensure that this throws
95+ @test_throws EOFError Tar. tree_hash (tarball)
96+ end
97+ end
98+
8799if ! Sys. iswindows ()
88100 @testset " POSIX extended headers" begin
89101 # make a test POSIX tarball with GNU `tar` from Tar_jll instead of Tar.create
You can’t perform that action at this time.
0 commit comments