From: pcarana Date: Tue, 16 Apr 2019 23:09:31 +0000 (-0500) Subject: Allow ASN 0 at CSV parsing X-Git-Tag: v0.0.2~49^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f838f5f2ee676944b50da17ac431b27979827aaf;p=thirdparty%2FFORT-validator.git Allow ASN 0 at CSV parsing --- diff --git a/src/csv.c b/src/csv.c index 880cacb1..1da645dc 100644 --- a/src/csv.c +++ b/src/csv.c @@ -19,7 +19,7 @@ ARRAY_LIST(vrplist, struct vrp) static int parse_asn(char *text, unsigned int *value) { - unsigned long asn; + long asn; char *start; if (text == NULL) { @@ -32,14 +32,14 @@ parse_asn(char *text, unsigned int *value) start = start != NULL ? start + 1 : text; errno = 0; - asn = strtoul(start, NULL, 10); + asn = strtol(start, NULL, 10); if (errno) { warn("Invalid ASN '%s'", text); return -EINVAL; } /* An underflow or overflow will be considered here */ - if (asn <= 0 || UINT32_MAX < asn) { - warnx("ASN (%lu) is out of range [1 - %u].", asn, UINT32_MAX); + if (asn < 0 || UINT32_MAX < asn) { + warnx("ASN (%ld) is out of range [0 - %u].", asn, UINT32_MAX); return -EINVAL; } *value = (unsigned int) asn;