mirror of
https://git.suckless.org/slock
synced 2026-10-12 06:42:25 +00:00
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:
committed by
Hiltjo Posthuma
parent
3791a996e2
commit
55d985a354
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user