Skip to content

fix(gui): harden bitmap allocation and filename decoding - #7975

Open
thomaskistler wants to merge 2 commits into
EdgeTX:mainfrom
thomaskistler:thomaskistler/bitmap-decoder-cleanup
Open

thomaskistler wants to merge 2 commits into
EdgeTX:mainfrom
thomaskistler:thomaskistler/bitmap-decoder-cleanup

Conversation

@thomaskistler

@thomaskistler thomaskistler commented Nov 2, 2026 •

Copy link
Copy Markdown

Fixes: N/A

Summary of changes

  • Reject overflow-prone owned BitmapBuffer allocations and compute null-safe, size_t storage bounds in both constructors and setData().
  • Reject filename images whose width or height cannot fit LVGL's 11-bit image descriptor, both when reading headers and after decoding.
  • Preserve grayscale-alpha PNG color and alpha in the STB filename decoder.
  • Add seven dedicated buffer/filename-decoder regressions covering allocation overflow, null storage bounds, borrowed storage updates, accepted and rejected image dimensions, direct open-callback validation, and exact grayscale-alpha pixel conversion.

This is an independent fix against main, with no prerequisite PRs. It changes only the general allocation code in bitmapbuffer.cpp, the existing filename decoder in bitmapbuffer_fileio.cpp, and dedicated tests in radio/src/tests/bitmapbuffer.cpp.

The allocation code includes <limits> explicitly, and the filename decoder keeps its dimension limit local. The existing BitmapBuffer header, resizeToLVGL() API/implementation, and loadBitmap() behavior are unchanged. No Lua hardening or lvgl.bitmap feature changes are included.

Validation

  • cmake --build build/native --target gtests-radio --parallel 6: passed.
  • build/native/gtests-radio --gtest_filter='BitmapBuffer.*:BitmapFilenameDecoder.*': 7/7 passed.
  • build/native/gtests-radio: 250/250 passed.
  • DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib build/native/gtests-radio --gtest_filter='BitmapBuffer.*:BitmapFilenameDecoder.*:Lua*:Lcd*:MainWindow.*': 35/35 passed with GuardMalloc loaded.
  • build/native/gtests-radio --gtest_filter='BitmapBuffer.*:BitmapFilenameDecoder.*:Lua*:Lcd*:MainWindow.*' --gtest_shuffle --gtest_repeat=10 --gtest_random_seed=41827: all ten 35-test iterations passed.

Temporary decoder fixtures were removed after validation.

Not performed: ARM firmware or Companion builds, hardware performance measurements, or radio heap measurements.

thomaskistler and others added 2 commits November 2, 2026 22:00
Guard BitmapBuffer allocation arithmetic and null storage bounds. Reject filename images outside LVGL descriptor limits and preserve grayscale-alpha PNG pixels in the STB filename decoder.

Add dedicated buffer and decoder regression coverage with temporary fixture cleanup.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Include allocation limits explicitly and keep the filename descriptor limit local to the decoder. Test allocation and storage bounds without invoking image resizing, retaining the existing resize API unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@thomaskistler
thomaskistler force-pushed the thomaskistler/bitmap-decoder-cleanup branch from 9f7e67e to 255895a Compare November 3, 2026 06:02

This branch has not been deployed

No deployments
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.

2 participants