Skip to content

Commit f5d855e

Browse files
committed
[klauspost/deflate-improve-comp] Use pre-compressed bytes for test.
Change-Id: Ie3630fc4b51f30108909a3d5930ffe17851f4a94
1 parent f09b893 commit f5d855e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/debug/elf/file_test.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package elf
77
import (
88
"bytes"
99
"compress/gzip"
10-
"compress/zlib"
1110
"debug/dwarf"
1211
"encoding/binary"
1312
"errors"
@@ -1560,18 +1559,9 @@ func TestIssue59208(t *testing.T) {
15601559
zoffset := sec.Offset + uint64(sec.compressionOffset)
15611560
copy(dn, data[:zoffset])
15621561

1563-
ozd, err := sec.Data()
1564-
if err != nil {
1565-
t.Fatal(err)
1566-
}
1567-
buf := bytes.NewBuffer(nil)
1568-
wr := zlib.NewWriter(buf)
15691562
// corrupt origin data same as COMPRESS_ZLIB
1570-
copy(ozd, []byte{1, 0, 0, 0})
1571-
wr.Write(ozd)
1572-
wr.Close()
1573-
1574-
copy(dn[zoffset:], buf.Bytes())
1563+
// Insert zlib compressed sec.Data() block with `[]byte{1, 0, 0, 0}` as the first 4 bytes
1564+
copy(dn[zoffset:], []byte{0x78, 0x9c, 0x5c, 0x4d, 0xb9, 0xd, 0x80, 0x30, 0xc, 0x3c, 0x7, 0x27, 0xdc, 0xe, 0xc, 0x46, 0x4b, 0x8b, 0x14, 0x51, 0x20, 0x16, 0xa1, 0x67, 0x8b, 0x2c, 0x88, 0xec, 0x44, 0xc2, 0xe2, 0x8a, 0xdc, 0x1b, 0x59, 0x0, 0x28, 0xc, 0x34, 0x9, 0x7f, 0x22, 0x96, 0xa0, 0x13, 0x67, 0x27, 0xa1, 0x53, 0xea, 0x4e, 0x47, 0x58, 0x7a, 0x98, 0x8d, 0x26, 0xcd, 0xfb, 0x71, 0x21, 0x31, 0x87, 0x7f, 0xca, 0xf3, 0x1b, 0x7a, 0x21, 0xfa, 0x3f, 0x23, 0x4f, 0x3, 0x50, 0x7a, 0xb9, 0xda, 0xfc, 0xae, 0xc3, 0x35, 0x77, 0x1b, 0x94, 0xd5, 0x82, 0x37, 0x0, 0x0, 0xff, 0xff, 0x65, 0xfb, 0x7, 0x6e})
15751565
copy(dn[sec.Offset+sec.FileSize:], data[sec.Offset+sec.FileSize:])
15761566

15771567
nf, err := NewFile(bytes.NewReader(dn))

0 commit comments

Comments
 (0)