Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer divide by zero when checking against section alignment anomaly #3

Closed
actuallyachraf opened this issue Mar 14, 2021 · 1 comment · May be fixed by #4
Closed

Integer divide by zero when checking against section alignment anomaly #3

actuallyachraf opened this issue Mar 14, 2021 · 1 comment · May be fixed by #4
Assignees
Labels
bug Something isn't working fuzz Reference a fuzzing crash

Comments

@actuallyachraf
Copy link
Contributor

While running a fuzzing session using the corkami corpus (corpus/) a certain file triggers a divide by zero panic when computing the modulo against section alignment of the file.

Resulting crash :

panic: runtime error: integer divide by zero

goroutine 1 [running]:
github.com/saferwall/pe.(*File).ParseNTHeader.func6(...)
	/home/echo/projects/saferwall/pe/ntheader.go:444
github.com/saferwall/pe.(*File).ParseNTHeader(0xc0000ac240, 0x0, 0x0)
	/home/echo/projects/saferwall/pe/ntheader.go:444 +0xf3e
github.com/saferwall/pe.(*File).Parse(0xc0000ac240, 0xc0000ac240, 0x604e02c3)
	/home/echo/projects/saferwall/pe/file.go:129 +0x127
github.com/saferwall/pe.Fuzz(0x7f0e504b5000, 0x138, 0x138, 0x4)
	/home/echo/projects/saferwall/pe/fuzz.go:10 +0x146
go-fuzz-dep.Main(0xc00004ff70, 0x1, 0x1)
	go-fuzz-dep/main.go:36 +0x1b8
main.main()
	github.com/saferwall/pe/go.fuzz.main/main.go:15 +0x52
exit status 2

Code responsible :

// The msdn states that SizeOfImage must be a multiple of the section
	// alignment. This is not true though. Adding it as anomaly.
	if (pe.Is32 && oh32.SizeOfImage%oh32.SectionAlignment != 0) ||
		(pe.Is64 && oh64.SizeOfImage%oh64.SectionAlignment != 0) {
		pe.Anomalies = append(pe.Anomalies, AnoInvalidSizeOfImage)
	}

This issue has been fixed and is here as reference.

@actuallyachraf actuallyachraf added the fuzz Reference a fuzzing crash label Mar 14, 2021
@actuallyachraf actuallyachraf linked a pull request Mar 14, 2021 that will close this issue
@LordNoteworthy LordNoteworthy self-assigned this Apr 12, 2022
@LordNoteworthy LordNoteworthy added the bug Something isn't working label Apr 12, 2022
@LordNoteworthy
Copy link
Member

@actuallyachraf I fixed this one, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fuzz Reference a fuzzing crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants