From c9f67897c483ff9ad436fad0682e2fa1d2c2406a Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Wed, 25 Sep 2024 23:30:39 +0700 Subject: [PATCH] fix(http): prevent `addCNameIfAvailable` from using closed `Dialer` (#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 --- pkg/protocols/http/request.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/protocols/http/request.go b/pkg/protocols/http/request.go index 5a1219b83f..180ee512ce 100644 --- a/pkg/protocols/http/request.go +++ b/pkg/protocols/http/request.go @@ -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) {