We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab978c0 commit bca0896Copy full SHA for bca0896
src/libdhcpcd/wpa.c
@@ -255,16 +255,19 @@ dhcpcd_wi_scans_free(DHCPCD_WI_SCAN *wis)
255
}
256
257
258
-static void
+static int
259
dhcpcd_strtoi(int *val, const char *s)
260
{
261
long l;
262
263
l = strtol(s, NULL, 0);
264
- if (l >= INT_MIN && l <= INT_MAX)
265
- *val = (int)l;
266
- else
+ if (l < INT_MIN || l > INT_MAX) {
267
errno = ERANGE;
+ return -1;
+ }
268
+
269
+ *val = (int)l;
270
+ return 0;
271
272
273
static int
@@ -1303,7 +1306,8 @@ dhcpcd_wpa_freq(DHCPCD_WPA *wpa)
1303
1306
if (*s == '\0')
1304
1307
continue;
1305
1308
if (strncmp(s, "freq=", 5) == 0) {
- dhcpcd_strtoi(&freq, s + 5);
1309
+ if (dhcpcd_strtoi(&freq, s + 5) == -1)
1310
1311
return freq;
1312
1313
0 commit comments