Commit Graph
15 Commits
Author SHA1 Message Date
Jonathan YenandClaude Opus 5 d515458973 fix: heap overflow in pm3_grabbed_output_get
pm3_grabbed_output_get null-terminated the captured output at
g_grabbed_output.size, but size is the allocated capacity, not the number of
bytes written -- ui.c grows it by MAX_PRINT_BUFFER at a time and tracks the
used length separately in idx. Every call therefore wrote one zero byte past
the end of the heap allocation.

The CLI mostly survives it because it calls the function once or twice and
then exits, so the corrupted malloc metadata is never reused. A long-running
libpm3 client that captures output on every command does not: the damage
surfaces later, far from the cause. It was found as a SIGTRAP inside an
unrelated AppKit autorelease pool.

Reproduced against real hardware:

  MALLOC_STRICT_SIZE=1 MallocGuardEdges=1 \
    DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib ./pm3run <port> "hw version"

which crashes with SIGSEGV inside pm3_grabbed_output_get before this change
and exits cleanly with identical captured output after it.

Terminating at idx is always in bounds: the grabber guarantees at least
MAX_PRINT_BUFFER bytes of headroom before each write, so idx is strictly less
than size.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AjGgtnsvWJHAMYEksAiYuf
2026-08-20 21:44:36 -04:00
Philippe Teuwen de96479d80 pm3_console() in Python/Lua/C: replace passthru by capture and quiet 2024-10-29 21:13:38 +01:00
Philippe Teuwen 0c21da8be0 pm3_lib: load preferences file 2024-10-14 18:36:54 +02:00
Philippe Teuwen 7eb71e0b06 grabber: make sure grabbed_output always return a string 2024-08-31 15:16:45 +02:00
Philippe Teuwen 55cef35b1d grabber: empty buffer after being read, to prevent old buffer to be returned after a command without output 2024-08-31 01:01:51 +02:00
Philippe Teuwen 369c5bb5db Added native output grabbing for Python and Lua: less hacky than output_grabber.py, should work on ProxSpace as well 2024-08-14 13:53:20 +02:00
iceman1001 0c4a1066c1 text 2024-01-05 19:27:38 +01:00
Eric Betts 4c9f611141 Be more CONSTant with the parameters we will not modify 2022-01-17 14:56:47 -08:00
Philippe Teuwen 30aa7aa7d1 Adapting license headers, WIP 2022-01-08 00:40:52 +01:00
Philippe Teuwen d37547917e cppcheck fix name difference declaration/definition 2021-09-05 20:35:40 +02:00
Philippe Teuwen 5fce6271ee rename typedef struct pm3_device 2021-08-21 21:41:52 +02:00
Philippe Teuwen dd3b63ae32 rename global session 2021-08-21 20:31:05 +02:00
Philippe Teuwen 6a2f2b3979 rename global conn 2021-08-21 20:21:08 +02:00
Philippe Teuwen 59667e5d1b make style (linux) 2020-11-29 00:28:56 +01:00
Philippe Teuwen eadacd82f5 SWIG experiments
Squash of the following commits (a full rebase was too hard :( )
* ef309cfdf N - SWIG: create pm3.c (5 months ago)  <Philippe Teuwen>
* 05ba6a73f N - swig pm3_device -> pm3 (5 months ago)  <Philippe Teuwen>
* d59630183 N - swig: move pm3.i (5 months ago)  <Philippe Teuwen>
* 6adcfad75 N - Fix historic make & cmake (5 months ago)  <Philippe Teuwen>
* bcbef2edf N - Fix typo with script_embedded (5 months ago)  <slurdge>
* 538ee4dab N - Better SWIG integration: autogen func & attributes (5 months ago)  <slurdge>
* 756b62466 N - SWIG: few helper scripts (5 months ago)  <Philippe Teuwen>
* 47ba4acd0 N - SWIG %extend (5 months ago)  <Philippe Teuwen>
* 21841cb9d N - simplify scripts (5 months ago)  <Philippe Teuwen>
* 78c4f7929 N - Revert "SWIG experiments: introduce context" (5 months ago)  <Philippe Teuwen>
* 1562b75fc N - SWIG experiments: introduce context (5 months ago)  <Philippe Teuwen>
* a503dfcd9 N - SWIG experiments (5 months ago)  <Philippe Teuwen>
2020-11-10 23:27:21 +01:00