Skip to content

Commit

Permalink
fix(http): prevent addCNameIfAvailable from using closed Dialer (p…
Browse files Browse the repository at this point in the history
…rojectdiscovery#5665)

added a check in `addCNameIfAvailable` to ensure
the `Dialer` isnot NIL before attempting to fetch
DNS data.

this prevents potential panics (ex. SIGSEGV) when
the `Dialer` is closed due to an interruption.

Signed-off-by: Dwi Siswanto <[email protected]>
  • Loading branch information
dwisiswant0 authored Sep 25, 2024
1 parent c93a2b1 commit c9f6789
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/protocols/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,10 @@ func (request *Request) validateNFixEvent(input *contextargs.Context, gr *genera

// addCNameIfAvailable adds the cname to the event if available
func (request *Request) addCNameIfAvailable(hostname string, outputEvent map[string]interface{}) {
if protocolstate.Dialer == nil {
return
}

data, err := protocolstate.Dialer.GetDNSData(hostname)
if err == nil {
switch len(data.CNAME) {
Expand Down

0 comments on commit c9f6789

Please sign in to comment.