mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-28 21:20:48 +00:00
lib: some ASNUMs should be forbidden
In current code, some ASNUMs with redundant zero are legal, e.g. "1.01", "01.1", "1.001", "001.1", and more. They should be forbidden. Signed-off-by: anlan_cs <vic.lan@pica8.com>
This commit is contained in:
parent
ee0aaff4bc
commit
b7d890dd45
12
lib/asn.c
12
lib/asn.c
@ -52,6 +52,10 @@ static bool asn_str2asn_internal(const char *asstring, as_t *asn,
|
||||
if (!isdigit((unsigned char)*p))
|
||||
goto end;
|
||||
|
||||
/* leading zero is forbidden */
|
||||
if (*p == '0' && isdigit((unsigned char)*(p + 1)))
|
||||
goto end;
|
||||
|
||||
temp_val = 0;
|
||||
while (isdigit((unsigned char)*p)) {
|
||||
digit = (*p) - '0';
|
||||
@ -65,11 +69,17 @@ static bool asn_str2asn_internal(const char *asstring, as_t *asn,
|
||||
high = (uint32_t)temp_val;
|
||||
if (*p == '.') { /* dot format */
|
||||
p++;
|
||||
temp_val = 0;
|
||||
|
||||
if (*p == '\0' && partial) {
|
||||
*partial = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* leading zero is forbidden */
|
||||
if (*p == '0' && isdigit((unsigned char)*(p + 1)))
|
||||
goto end;
|
||||
|
||||
temp_val = 0;
|
||||
while (isdigit((unsigned char)*p)) {
|
||||
digit = (*p) - '0';
|
||||
temp_val *= 10;
|
||||
|
Loading…
Reference in New Issue
Block a user