From b1571febfdc41a8ae84ea49e55cec0ee141d272b Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Sun, 30 Aug 2026 01:10:31 +0300 Subject: [PATCH] fb: Avoid potential out-of-bounds shift amounts in fbBlt In fbBlt(), explicitly check (srcX < dstX) in the alternate shift calculation branch so that shift values (leftShift and rightShift) remain strictly within valid bit-width bounds [0..FB_UNIT - 1], avoiding potential 32-bit shift undefined behavior warnings --- fb/fbblt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fb/fbblt.c b/fb/fbblt.c index e7b06c283..bb0183aca 100644 --- a/fb/fbblt.c +++ b/fb/fbblt.c @@ -222,10 +222,14 @@ fbBlt(FbBits * srcLine, leftShift = srcX - dstX; rightShift = FB_UNIT - leftShift; } - else { + else if (srcX < dstX) { rightShift = dstX - srcX; leftShift = FB_UNIT - rightShift; } + else { + leftShift = 0; + rightShift = 0; + } while (height--) { src = srcLine; srcLine += srcStride;