Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4a6dfda4
Commit
4a6dfda4
authored
Apr 01, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug/macho: don't crash when reading non-Mach-O files
R=rsc CC=golang-dev
https://golang.org/cl/838046
parent
d4a16197
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
src/pkg/debug/macho/file.go
src/pkg/debug/macho/file.go
+3
-1
src/pkg/debug/macho/file_test.go
src/pkg/debug/macho/file_test.go
+8
-0
No files found.
src/pkg/debug/macho/file.go
View file @
4a6dfda4
...
...
@@ -167,7 +167,7 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
// Read and decode Mach magic to determine byte order, size.
// Magic32 and Magic64 differ only in the bottom bit.
var
ident
[
4
]
uint8
var
ident
[
4
]
byte
if
_
,
err
:=
r
.
ReadAt
(
&
ident
,
0
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -180,6 +180,8 @@ func NewFile(r io.ReaderAt) (*File, os.Error) {
case
le
&^
1
:
f
.
ByteOrder
=
binary
.
LittleEndian
f
.
Magic
=
le
default
:
return
nil
,
&
FormatError
{
0
,
"invalid magic number"
,
nil
}
}
// Read entire file header.
...
...
src/pkg/debug/macho/file_test.go
View file @
4a6dfda4
...
...
@@ -157,3 +157,11 @@ func TestOpen(t *testing.T) {
}
}
func
TestOpenFailure
(
t
*
testing
.
T
)
{
filename
:=
"file.go"
// not a Mach-O file
_
,
err
:=
Open
(
filename
)
// don't crash
if
err
==
nil
{
t
.
Errorf
(
"open %s: succeeded unexpectedly"
,
filename
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment