summaryrefslogtreecommitdiff
path: root/lib/command_match.c
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <Jafaral@users.noreply.github.com>2019-10-07 13:05:09 -0700
committerGitHub <noreply@github.com>2019-10-07 13:05:09 -0700
commit4668ac905cf97e298fbc1b11929c64bc7b5a60af (patch)
treee578412a1bf21fdce9cc1ac5ae20313e8220681c /lib/command_match.c
parentf7192aa119fd9f6b01f2288d6310baacb5dcf655 (diff)
parente843208299db9a2ebf3b22e21e1a6d33cfdc35af (diff)
Merge pull request #5112 from qlyoung/cli-reject-ipv4-leading-zero
lib: reject leading 0 in ipv4 decimal quad
Diffstat (limited to 'lib/command_match.c')
-rw-r--r--lib/command_match.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/command_match.c b/lib/command_match.c
index 26d763849d..0195aebc17 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -724,7 +724,12 @@ static enum match_type match_ipv4(const char *str)
return no_match;
memcpy(buf, sp, str - sp);
- if (atoi(buf) > 255)
+
+ int v = atoi(buf);
+
+ if (v > 255)
+ return no_match;
+ if (v > 0 && buf[0] == '0')
return no_match;
nums++;
@@ -775,7 +780,12 @@ static enum match_type match_ipv4_prefix(const char *str)
return no_match;
memcpy(buf, sp, str - sp);
- if (atoi(buf) > 255)
+
+ int v = atoi(buf);
+
+ if (v > 255)
+ return no_match;
+ if (v > 0 && buf[0] == '0')
return no_match;
if (dots == 3) {