summaryrefslogtreecommitdiff
path: root/lib/command_match.c
diff options
context:
space:
mode:
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) {