Avoid ctype(3) abuses

Valid argument of ctype(3) functions must be either EOF or non-negative
value within the range representable as unsigned char. Invalid values
leads to undefined behavior.

Cast all such uses to avoid that.

At least in NetBSD 11 ctype(3) abuses will always crash and permit
to break slock screen locking.
This commit is contained in:
Leonardo Taccari
2026-07-27 23:53:20 +02:00
committed by Hiltjo Posthuma
parent 3791a996e2
commit 55d985a354
+1 -1
View File
@@ -181,7 +181,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
passwd[--len] = '\0';
break;
default:
if (num && !iscntrl((int)buf[0]) &&
if (num && !iscntrl((unsigned char)buf[0]) &&
(len + num < sizeof(passwd))) {
memcpy(passwd + len, buf, num);
len += num;