strnatcmp.c: ensure correct value range for isdigit() argument.

The valid values to pass to `isdigit()` is the values represented
by `unsigned char` and the value of EOF (usually -1).  Other values
such as the other negative `signed char` values may invoke undefined
behaviour.

Fix this by casting the argument to `isdigit()` to `unsigned char`.

Found by building on NetBSD/macppc with -Wchar-subscripts turned on.
pull/1159/head
Havard Eidnes 1 year ago
parent 34f026e444
commit f5daea2273

@ -275,13 +275,13 @@ int ipv4cmp(int a_len, nat_char const *a,
}
for (; ai < a_len; ai++) {
if (!isdigit(a[ai]) || a[ai] != '.') {
if (!isdigit((unsigned char)a[ai]) || a[ai] != '.') {
return 0;
}
}
for (; bi < b_len; bi++) {
if (!isdigit(b[bi]) || b[bi] != '.') {
if (!isdigit((unsigned char)b[bi]) || b[bi] != '.') {
return 0;
}
}

Loading…
Cancel
Save