1
0
mirror of https://github.com/golang/go synced 2024-11-17 05:24:53 -07:00

archive/tar: check returned error before use hdr

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guoguangwu 2024-02-25 20:53:35 +08:00
parent 08d9397170
commit a11a803602

View File

@ -581,10 +581,10 @@ func TestPaxSymlink(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
hdr, err := FileInfoHeader(fileinfo, "") hdr, err := FileInfoHeader(fileinfo, "")
hdr.Typeflag = TypeSymlink
if err != nil { if err != nil {
t.Fatalf("os.Stat:1 %v", err) t.Fatalf("os.Stat:1 %v", err)
} }
hdr.Typeflag = TypeSymlink
// Force a PAX long linkname to be written // Force a PAX long linkname to be written
longLinkname := strings.Repeat("1234567890/1234567890", 10) longLinkname := strings.Repeat("1234567890/1234567890", 10)
hdr.Linkname = longLinkname hdr.Linkname = longLinkname
@ -761,10 +761,10 @@ func TestUSTARLongName(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
hdr, err := FileInfoHeader(fileinfo, "") hdr, err := FileInfoHeader(fileinfo, "")
hdr.Typeflag = TypeDir
if err != nil { if err != nil {
t.Fatalf("os.Stat:1 %v", err) t.Fatalf("os.Stat:1 %v", err)
} }
hdr.Typeflag = TypeDir
// Force a PAX long name to be written. The name was taken from a practical example // Force a PAX long name to be written. The name was taken from a practical example
// that fails and replaced ever char through numbers to anonymize the sample. // that fails and replaced ever char through numbers to anonymize the sample.
longName := "/0000_0000000/00000-000000000/0000_0000000/00000-0000000000000/0000_0000000/00000-0000000-00000000/0000_0000000/00000000/0000_0000000/000/0000_0000000/00000000v00/0000_0000000/000000/0000_0000000/0000000/0000_0000000/00000y-00/0000/0000/00000000/0x000000/" longName := "/0000_0000000/00000-000000000/0000_0000000/00000-0000000000000/0000_0000000/00000-0000000-00000000/0000_0000000/00000000/0000_0000000/000/0000_0000000/00000000v00/0000_0000000/000000/0000_0000000/0000000/0000_0000000/00000y-00/0000/0000/00000000/0x000000/"