]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Allow ASN 0 at CSV parsing
authorpcarana <pc.moreno2099@gmail.com>
Tue, 16 Apr 2019 23:09:31 +0000 (18:09 -0500)
committerpcarana <pc.moreno2099@gmail.com>
Tue, 16 Apr 2019 23:09:31 +0000 (18:09 -0500)
src/csv.c

index 880cacb19ad72a8be75491e2baaade7aaddf5cd4..1da645dcc9ed561581553d88839e642297de055d 100644 (file)
--- 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;