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

Fix npe on debug output #439

Merged
merged 1 commit into from
Nov 22, 2021
Merged

Conversation

zerodivisi0n
Copy link
Contributor

Fix panic in debug output on unsuccessful request - #425 (comment).

$ echo abc | ./httpx -debug
...
panic: runtime error: invalid memory address or nil pointer dereference                                                                             
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa54a09]

goroutine 27 [running]:
github.com/projectdiscovery/httpx/runner.(*Runner).analyze(_, _, {_, _}, {_, _}, {_, _}, {0xc00023e070, 0x3}, ...)
        /home/zerodivisi0n/go/src/github.com/projectdiscovery/httpx/runner/runner.go:855 +0x1089
github.com/projectdiscovery/httpx/runner.(*Runner).process.func1({0xc00023e070, 0x3}, {0xba3512, 0x3}, {0xba9fbb, 0xa})
        /home/zerodivisi0n/go/src/github.com/projectdiscovery/httpx/runner/runner.go:648 +0x125
created by github.com/projectdiscovery/httpx/runner.(*Runner).process
        /home/zerodivisi0n/go/src/github.com/projectdiscovery/httpx/runner/runner.go:646 +0x945

The panic occurs here:

gologger.Print().Msgf("%s", string(resp.Raw))

I decided to add a check here, and not below (after handling the error) so that the request body is always displayed and the code with the debug output is in one place.

@ehsandeep ehsandeep linked an issue Nov 22, 2021 that may be closed by this pull request
@ehsandeep ehsandeep requested a review from Mzack9999 November 22, 2021 08:27
@ehsandeep ehsandeep added Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Nov 22, 2021
@ehsandeep ehsandeep removed the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Nov 22, 2021
@ehsandeep ehsandeep merged commit a1b0a89 into projectdiscovery:dev Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalid memory address or nil pointer dereference with debug flag
3 participants