fix: make CodeQL happy Dreamacro

This commit is contained in:
gVisor bot 2022-06-01 21:38:05 +08:00
parent e488342451
commit 58e44ed27c
2 changed files with 4 additions and 4 deletions

View file

@ -72,14 +72,14 @@ func (u *Uid) RuleType() C.RuleType {
} }
func (u *Uid) Match(metadata *C.Metadata) bool { 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 { if err != nil {
return false return false
} }
var uid int32 var uid int32
if metadata.Uid != nil { if metadata.Uid != nil {
uid = *metadata.Uid 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 metadata.Uid = &uid
} else { } else {
log.Warnln("[UID] could not get uid from %s", metadata.String()) log.Warnln("[UID] could not get uid from %s", metadata.String())

View file

@ -181,9 +181,9 @@ func preHandleMetadata(metadata *C.Metadata) error {
} }
// pre resolve process name // pre resolve process name
srcPort, err := strconv.Atoi(metadata.SrcPort) srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16)
if err == nil && P.ShouldFindProcess(metadata) { 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 err != nil {
if failTotal < 20 { if failTotal < 20 {
log.Debugln("[Process] find process %s: %v", metadata.String(), err) log.Debugln("[Process] find process %s: %v", metadata.String(), err)