Files
RedBear-OS/local
vasilito f10a0ec89c xwayland: restore button mapping switch to fix uninitialized index
The Round 6 audit found that the redox.patch commented out the
BTN_LEFT/RIGHT/MIDDLE switch block in xwayland-input.c. The
block was originally used to map Linux input button codes to X11
button indices:

  BTN_LEFT (0x110)   -> index 1 (X11 button 1)
  BTN_MIDDLE (0x112) -> index 2 (X11 button 2)
  BTN_RIGHT (0x111)  -> index 3 (X11 button 3)
  BTN_SIDE+ (0x113+) -> index 8 + offset

The block was commented out but the 'index' variable was used
later uninitialized, causing undefined behavior at X server run
time when relibc lacks <linux/input.h>.

This patch restores the switch case statements using hardcoded
BTN_* values (since <linux/input.h> is not available on Redox).
The Linux BTN_* constants are:
  BTN_LEFT   = 0x110
  BTN_RIGHT  = 0x111
  BTN_MIDDLE = 0x112
  BTN_SIDE   = 0x113

Mouse button events now correctly produce X11 button indices
1, 2, 3 for left/middle/right clicks. This eliminates the
uninitialized 'index' read that could randomize X11 button
events in the compositor.

The <linux/input.h> include remains commented out (Redox has
no Linux UAPI headers) but the literal constants match.
2026-07-27 08:11:50 +09:00
..