mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-08 21:56:48 +02:00
net/netstat: add nil checks to Windows OSMetadata implementation
The API documentation does claim to output empty strings under certain conditions, but we're sometimes seeing nil pointers in the wild, not empty strings. Fixes https://github.com/tailscale/corp/issues/8878 Signed-off-by: Aaron Klotz <aaron@tailscale.com> (cherry picked from commit 4a869048bf0ed15a292b23d3cd776b4ef96ca451)
This commit is contained in:
parent
d1fc9bba7e
commit
a3ce35d0c6
@ -224,6 +224,7 @@ type moduleInfoConstraint interface {
|
||||
_MIB_TCPROW_OWNER_MODULE | _MIB_TCP6ROW_OWNER_MODULE
|
||||
}
|
||||
|
||||
// moduleInfo may return "", nil indicating a successful call but with empty data
|
||||
func moduleInfo[entryType moduleInfoConstraint](entry *entryType, proc *windows.LazyProc) (string, error) {
|
||||
var buf []byte
|
||||
var desiredLen uint32
|
||||
@ -249,6 +250,12 @@ func moduleInfo[entryType moduleInfoConstraint](entry *entryType, proc *windows.
|
||||
}
|
||||
|
||||
basicInfo := (*_TCPIP_OWNER_MODULE_BASIC_INFO)(addr)
|
||||
// GetOwnerModuleFromTcp*Entry is apparently using nil as an empty result
|
||||
// under certain circumstances, so we check all the things.
|
||||
if basicInfo == nil || basicInfo.moduleName == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
return windows.UTF16PtrToString(basicInfo.moduleName), nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user