Skip to content

tray: accept BMP icons whose declared size is bounded - #5527

Open
ShrimpTale wants to merge 1 commit into
Alexays:masterfrom
ShrimpTale:tray-bmp-icon
Open

ShrimpTale wants to merge 1 commit into
Alexays:masterfrom
ShrimpTale:tray-bmp-icon

Conversation

@ShrimpTale

Copy link
Copy Markdown

What does this PR do?

Tray items whose IconName is a BMP file are decoded again, bounded by the same
MAX_ICON_FILE_PIXELS limit that already applies to PNG.

Since 0.16.0 loadIconFromFile() only accepts PNG and SVG, so those items fall back to
image-missing and log:

Tray: refusing icon file '/tmp/SDL-tray-K7BOZ3/0.bmp': not a PNG of at most 16777216 pixels or an SVG

0.15.x decoded whatever the item named with Gdk::Pixbuf::create_from_file(), so this is a
regression for any SDL application with a tray icon. SDL's tray support wrote the icon as a
temporary BMP for libayatana-appindicator until 3.4 (SDL_SaveBMP() in
src/tray/unix/SDL_tray.c); SDL 3.4 switched to PNG, but applications built against older SDL —
and other toolkits that still write BMP — keep handing out .bmp paths.

Concrete case: BongoCat 1.12.0 (SDL 3.2.31) on Arch with waybar 0.16.0 and the Papirus icon
theme. It is reachable today with tray.icons and a manual mapping, but that needs one entry per
application, keyed by an item ID that can contain the PID (sdl-appindicator-1987-0), for an
application the user does not control.

Why this keeps the bound

The existing check exists so that nothing is decoded before its declared size is known. A BMP
declares biWidth/biHeight in its DIB header, so the same bound runs before
create_from_stream_at_scale(). The file is still read through the opened descriptor, still
capped at 64 MiB, and still decoded at bar height.

Related issues

No tracking issue — happy to open one first if you would rather review it there.

Checklist

  • Code is formatted with clang-format (23.1.5, repo .clang-format)
  • Builds locally (meson setup build && ninja -C build → 350/350)
  • Man page updated — no user-facing option changed
  • Tested against the affected module: a real 512×512 BMP is accepted, a forged
    20000×20000 header is refused, negative (top-down) biHeight is handled

SDL's tray support wrote the icon as a temporary BMP for libayatana-appindicator
before SDL 3.4, and other toolkits still do. Those items rendered as
image-missing on waybar 0.15.0-3 -> 0.16.0 (their IconName is a file waybar
refused to decode).

Keep the existing bound instead of relaxing it: BMP states its size in the DIB
header, so the pixel limit is checked before anything is decoded, exactly like
the PNG path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant