From 5a7d94e07fc7e4a10d6399f5e44793fa0c896af6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 12 Nov 2024 12:40:04 -0800 Subject: xkb: avoid undefined behavior due to left shift overflow Closes: #225 Signed-off-by: Alan Coopersmith Part-of: --- src/xkb/XKBleds.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/xkb/XKBleds.c b/src/xkb/XKBleds.c index 5c51f276..8e75ea54 100644 --- a/src/xkb/XKBleds.c +++ b/src/xkb/XKBleds.c @@ -72,16 +72,14 @@ _XkbReadGetIndicatorMapReply(Display *dpy, leds->phys_indicators = rep->realIndicators; if (rep->length > 0) { - register int left; - if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4)) return BadAlloc; if (nread_rtrn) *nread_rtrn = (int) rep->length * 4; if (rep->which) { - register int i, bit; + unsigned int i, bit, left; - left = (int) rep->which; + left = rep->which; for (i = 0, bit = 1; (i < XkbNumIndicators) && (left); i++, bit <<= 1) { if (left & bit) { @@ -106,7 +104,7 @@ _XkbReadGetIndicatorMapReply(Display *dpy, } } } - left = _XkbFreeReadBuffer(&buf); + (void) _XkbFreeReadBuffer(&buf); } return Success; } -- cgit v1.2.3