From: Matteo Croce Date: Tue, 25 Jul 2017 13:30:31 +0000 (+0200) Subject: netns: more input validation X-Git-Tag: v4.13.0~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3f0b091976b73842f2dbfcecaba341fd204c635;p=thirdparty%2Fiproute2.git netns: more input validation ip netns accepts invalid input as namespace name like an empty string or a string longer than the maximum file name length. Check that the netns name is not empty and less than or equal to NAME_MAX. Signed-off-by: Matteo Croce --- diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 425499444..198e9de8c 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -768,7 +768,8 @@ static int netns_monitor(int argc, char **argv) static int invalid_name(const char *name) { - return strchr(name, '/') || !strcmp(name, ".") || !strcmp(name, ".."); + return !*name || strlen(name) > NAME_MAX || + strchr(name, '/') || !strcmp(name, ".") || !strcmp(name, ".."); } int do_netns(int argc, char **argv)