From 65d543329ec9c1327f8758a29e5d23fec3655aa7 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 12 Aug 2022 12:49:35 +0800 Subject: [PATCH] Fix: nil pointer --- constant/metadata.go | 4 ++-- tunnel/tunnel.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/constant/metadata.go b/constant/metadata.go index 633487ad..b58847ff 100644 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -127,9 +127,9 @@ func (m *Metadata) SourceDetail() string { return fmt.Sprintf("[%s]", ClashName) } - if m.Process != "" && *m.Uid != -1 { + if m.Process != "" && m.Uid != nil { return fmt.Sprintf("%s(%s, uid=%d)", m.SourceAddress(), m.Process, *m.Uid) - } else if *m.Uid != -1 { + } else if m.Uid != nil { return fmt.Sprintf("%s(uid=%d)", m.SourceAddress(), *m.Uid) } else if m.Process != "" { return fmt.Sprintf("%s(%s)", m.SourceAddress(), m.Process) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index a4b78558..3c74e14d 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -403,7 +403,9 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) { } else { metadata.Process = filepath.Base(path) metadata.ProcessPath = path - metadata.Uid = &uid + if uid != -1 { + metadata.Uid = &uid + } processFound = true } }