From ce90f82956272dbcea2cd098b9580296a0f988e9 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 5 Nov 2024 07:46:17 +0100 Subject: [PATCH] Disallow node names which are numbers --- config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config.go b/config.go index d3239b4..66cefc0 100644 --- a/config.go +++ b/config.go @@ -10,6 +10,7 @@ import ( "fmt" "net/netip" "os" + "strconv" "strings" ) @@ -155,6 +156,13 @@ func parseConfigNode(cfg *Config, args []string) error { res := Node{ Name: args[0], } + _, err := strconv.Atoi(res.Name) + if err == nil { + // `ip` "netns" option uses the PID's namespace when given a number + // but we need the namespace name. + return fmt.Errorf("invalid name %q (must not be a number)", + res.Name) + } if cfg.Nodes[res.Name] != nil { return fmt.Errorf("%q already exists", res.Name) } -- 2.45.2