Merge pull request #12866 from anlancs/lib/dotas-zero

lib: some ASNUMs should be forbidden
This commit is contained in:
Donatas Abraitis 2023-02-27 11:05:47 +02:00 committed by GitHub
commit 148ad13257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;