From 23063ae0b96066c940cd04c0a8c9de939b92bd1b Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+dreamacro@users.noreply.github.com> Date: Wed, 1 Jun 2022 21:38:05 +0800 Subject: [PATCH] fix: make CodeQL happy Dreamacro --- rules/common/uid.go | 4 ++-- tunnel/tunnel.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/common/uid.go b/rules/common/uid.go index d5321581..f7ea4875 100644 --- a/rules/common/uid.go +++ b/rules/common/uid.go @@ -72,14 +72,14 @@ func (u *Uid) RuleType() C.RuleType { } func (u *Uid) Match(metadata *C.Metadata) bool { - srcPort, err := strconv.Atoi(metadata.SrcPort) + srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16) if err != nil { return false } var uid int32 if metadata.Uid != nil { uid = *metadata.Uid - } else if uid, err = process.FindUid(metadata.NetWork.String(), metadata.SrcIP, srcPort); err == nil { + } else if uid, err = process.FindUid(metadata.NetWork.String(), metadata.SrcIP, int(srcPort)); err == nil { metadata.Uid = &uid } else { log.Warnln("[UID] could not get uid from %s", metadata.String()) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 936b2b48..b8038520 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -181,9 +181,9 @@ func preHandleMetadata(metadata *C.Metadata) error { } // pre resolve process name - srcPort, err := strconv.Atoi(metadata.SrcPort) + srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16) if err == nil && P.ShouldFindProcess(metadata) { - uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, srcPort) + uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort)) if err != nil { if failTotal < 20 { log.Debugln("[Process] find process %s: %v", metadata.String(), err)