mirror of
https://github.com/tstack/lnav
synced 2024-11-15 18:13:10 +00:00
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.
This commit is contained in:
parent
34f026e444
commit
f5daea2273
@ -275,13 +275,13 @@ int ipv4cmp(int a_len, nat_char const *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; ai < a_len; ai++) {
|
for (; ai < a_len; ai++) {
|
||||||
if (!isdigit(a[ai]) || a[ai] != '.') {
|
if (!isdigit((unsigned char)a[ai]) || a[ai] != '.') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; bi < b_len; bi++) {
|
for (; bi < b_len; bi++) {
|
||||||
if (!isdigit(b[bi]) || b[bi] != '.') {
|
if (!isdigit((unsigned char)b[bi]) || b[bi] != '.') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user