diff options
| author | Jafar Al-Gharaibeh <Jafaral@users.noreply.github.com> | 2019-10-07 13:05:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-07 13:05:09 -0700 |
| commit | 4668ac905cf97e298fbc1b11929c64bc7b5a60af (patch) | |
| tree | e578412a1bf21fdce9cc1ac5ae20313e8220681c /lib/command_match.c | |
| parent | f7192aa119fd9f6b01f2288d6310baacb5dcf655 (diff) | |
| parent | e843208299db9a2ebf3b22e21e1a6d33cfdc35af (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.c | 14 |
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) { |
