File tree 3 files changed +24
-22
lines changed
3 files changed +24
-22
lines changed Original file line number Diff line number Diff line change @@ -423,22 +423,10 @@ func TestTypeString(t *testing.T) {
423
423
}
424
424
}
425
425
426
- func TestNewFatFile (t * testing.T ) {
427
-
428
- f , err := os .Open ("/usr/lib/libLeaksAtExit.dylib" )
429
- if err != nil {
430
- t .Fatal (err )
431
- }
432
-
433
- fat , err := NewFatFile (f )
434
- if err != nil {
435
- t .Fatal (err )
436
- }
437
-
438
- fmt .Println (fat .Arches [0 ].FileTOC .String ())
439
-
440
- if fat .Arches [0 ].UUID ().UUID .String () != "273FB269-0D2F-3A78-9874-09E004F8B069" {
441
- t .Errorf ("macho.UUID() = %s; want test" , fat .Arches [0 ].UUID ())
426
+ func TestOpenBadDysymCmd (t * testing.T ) {
427
+ _ , err := openObscured ("internal/testdata/gcc-amd64-darwin-exec-with-bad-dysym.base64" )
428
+ if err == nil {
429
+ t .Fatal ("openObscured did not fail when opening a file with an invalid dynamic symbol table command" )
442
430
}
443
431
}
444
432
@@ -644,7 +632,7 @@ func TestNewFile(t *testing.T) {
644
632
if t1 , ok := typ .(* dwarf.StructType ); ok {
645
633
if strings .EqualFold (t1 .StructName , "thread" ) {
646
634
if ! t1 .Incomplete {
647
- fmt .Println (t1 .Defn ())
635
+ fmt .Println (t1 .Defn (false ))
648
636
}
649
637
}
650
638
}
Original file line number Diff line number Diff line change 1
- github.com/blacktop/go-dwarf v1.0.9 h1:eT/L7gt0gllvvgnRXY0MFKjNB6+jtOY5DTm2ynVX2dY =
2
- github.com/blacktop/go-dwarf v1.0.9 /go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo =
1
+ github.com/blacktop/go-dwarf v1.0.10 h1:i9zYgcIROETsNZ6V+zZn3uDH21FCG5BLLZ837GitxS0 =
2
+ github.com/blacktop/go-dwarf v1.0.10 /go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo =
Original file line number Diff line number Diff line change @@ -10,10 +10,24 @@ package obscuretestdata
10
10
import (
11
11
"encoding/base64"
12
12
"io"
13
- "io/ioutil"
14
13
"os"
15
14
)
16
15
16
+ // Rot13 returns the rot13 encoding or decoding of its input.
17
+ func Rot13 (data []byte ) []byte {
18
+ out := make ([]byte , len (data ))
19
+ copy (out , data )
20
+ for i , c := range out {
21
+ switch {
22
+ case 'A' <= c && c <= 'M' || 'a' <= c && c <= 'm' :
23
+ out [i ] = c + 13
24
+ case 'N' <= c && c <= 'Z' || 'n' <= c && c <= 'z' :
25
+ out [i ] = c - 13
26
+ }
27
+ }
28
+ return out
29
+ }
30
+
17
31
// DecodeToTempFile decodes the named file to a temporary location.
18
32
// If successful, it returns the path of the decoded file.
19
33
// The caller is responsible for ensuring that the temporary file is removed.
@@ -24,7 +38,7 @@ func DecodeToTempFile(name string) (path string, err error) {
24
38
}
25
39
defer f .Close ()
26
40
27
- tmp , err := ioutil . TempFile ("" , "obscuretestdata-decoded-" )
41
+ tmp , err := os . CreateTemp ("" , "obscuretestdata-decoded-" )
28
42
if err != nil {
29
43
return "" , err
30
44
}
@@ -47,5 +61,5 @@ func ReadFile(name string) ([]byte, error) {
47
61
return nil , err
48
62
}
49
63
defer f .Close ()
50
- return ioutil .ReadAll (base64 .NewDecoder (base64 .StdEncoding , f ))
64
+ return io .ReadAll (base64 .NewDecoder (base64 .StdEncoding , f ))
51
65
}
You can’t perform that action at this time.
0 commit comments