eap: Reset errno before calling strtoul() to parse EAP type
authorReinhard Pfau <reinhard.pfau@gdsys.cc>
Tue, 23 Jan 2018 09:09:14 +0000 (10:09 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 23 Jan 2018 09:09:14 +0000 (10:09 +0100)
Reset errno to 0 before calling strtoul() since it sets errno only on
error cases. So the following test fails even on correct conversions if
errno had a value != 0.

Fixes #2506.

src/libstrongswan/eap/eap.c

index 64b5dbe..2b7295e 100644 (file)
@@ -157,6 +157,7 @@ eap_vendor_type_t *eap_vendor_type_from_string(char *str)
                        type = eap_type_from_string(part);
                        if (!type)
                        {
+                               errno = 0;
                                type = strtoul(part, &end, 0);
                                if (*end != '\0' || errno)
                                {
@@ -166,6 +167,7 @@ eap_vendor_type_t *eap_vendor_type_from_string(char *str)
                        }
                        continue;
                }
+               errno = 0;
                vendor = strtoul(part, &end, 0);
                if (*end != '\0' || errno)
                {