Description
In gnmi_server/clientCertAuth.go around line 161, resp.StatusCode is accessed even when http.Get() returns (nil, err). The current code checks resp != nil for the defer but then unconditionally accesses resp.StatusCode in the error check.
Current code
resp, err := http.Get(url)
if resp != nil { defer resp.Body.Close() }
if err != nil || resp.StatusCode != http.StatusOK { // resp may be nil here!
Fix
Check err != nil first, return early, then access resp:
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
Impact
Panic in the gNMI server when client certificate authentication makes an HTTP call that fails at the network level.
Description
In
gnmi_server/clientCertAuth.goaround line 161,resp.StatusCodeis accessed even whenhttp.Get()returns(nil, err). The current code checksresp != nilfor the defer but then unconditionally accessesresp.StatusCodein the error check.Current code
Fix
Check
err != nilfirst, return early, then accessresp:Impact
Panic in the gNMI server when client certificate authentication makes an HTTP call that fails at the network level.