forked from Mirror/frr
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))
|
if (!isdigit((unsigned char)*p))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
/* leading zero is forbidden */
|
||||||
|
if (*p == '0' && isdigit((unsigned char)*(p + 1)))
|
||||||
|
goto end;
|
||||||
|
|
||||||
temp_val = 0;
|
temp_val = 0;
|
||||||
while (isdigit((unsigned char)*p)) {
|
while (isdigit((unsigned char)*p)) {
|
||||||
digit = (*p) - '0';
|
digit = (*p) - '0';
|
||||||
|
@ -65,11 +69,17 @@ static bool asn_str2asn_internal(const char *asstring, as_t *asn,
|
||||||
high = (uint32_t)temp_val;
|
high = (uint32_t)temp_val;
|
||||||
if (*p == '.') { /* dot format */
|
if (*p == '.') { /* dot format */
|
||||||
p++;
|
p++;
|
||||||
temp_val = 0;
|
|
||||||
if (*p == '\0' && partial) {
|
if (*p == '\0' && partial) {
|
||||||
*partial = true;
|
*partial = true;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* leading zero is forbidden */
|
||||||
|
if (*p == '0' && isdigit((unsigned char)*(p + 1)))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
temp_val = 0;
|
||||||
while (isdigit((unsigned char)*p)) {
|
while (isdigit((unsigned char)*p)) {
|
||||||
digit = (*p) - '0';
|
digit = (*p) - '0';
|
||||||
temp_val *= 10;
|
temp_val *= 10;
|
||||||
|
|
Loading…
Reference in a new issue