strcspn(line, " ") returns strlen(line) when the command has no
argument, so &line[strcspn(line, " ") + 1] pointed one byte past the
NUL terminator and strint_to_int32 parsed uninitialized memory (error
with garbage text, or a mouse_scroll/mouse_move executed with a garbage
value). Use ducky_get_command_len() like every other command in the file,
and reject MOUSEMOVE with a missing second argument with a proper
"Invalid Number" script error.
Generated by Mistral Vibe.
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
realloc() copied the new size out of the old block, so growing a block
read past its end: neighbouring heap data was copied into the new block,
and a block near the end of the heap could be read past the heap itself.
Copy the smaller of the old block's usable size and the new size. The
new memmgr_heap_get_block_size() reads the former from the block header.
calloc() multiplied count by size unchecked: calloc(0x40000001, 4)
wrapped to 4 bytes and returned a 4-byte block for a 4 GiB request.
Check with __builtin_mul_overflow() and stop on "out of memory", as for
any allocation that cannot be served.
The realloc() fault was reported in
flipperdevices/flipperzero-firmware#1274, and the same fix was proposed
in #977 (closed unmerged) and flipperdevices/flipperzero-firmware#4360
(open).
Claude-Session: https://claude.ai/code/session_0178Lh3xS7wvbg3ge5jTuQU7
Co-authored-by: Claude <noreply@anthropic.com>
Renaming a saved signal copies its name into file_name_tmp with
strncpy(..., SUBGHZ_MAX_LEN_NAME). A name of 64 characters or more
leaves the buffer unterminated, and the next byte of struct SubGhz
(state_notifications, 1 by then) ends up in the name. FatFs takes that
control character for the end of the path, so saving without any change
renames the file to its first 64 characters without the .sub extension,
and it drops out of the Saved list.
Use strlcpy(). OFW's version of this scene already does, since
flipperdevices/flipperzero-firmware#3866 replaced strncpy throughout,
and the change was also part of #977, as a compiler warning fix.
Claude-Session: https://claude.ai/code/session_0178Lh3xS7wvbg3ge5jTuQU7
Co-authored-by: Claude <noreply@anthropic.com>
gps_on_location() and network_on_event() read the callback and its
context under the lock, released it, then made the call. So
gps_set_location_callback() and network_set_event_callback() could
return while the old callback was still running, or about to start,
with a context the app frees right after unsubscribing.
Hold a recursive callback mutex across the call, and take it in the
setters: once a setter returns, the old callback has finished and will
not be called again. It is a separate mutex from the RPC bridge's, so a
callback can still send through the service. The guarantee, and the rule
that comes with it (do not call the setter while holding a lock the
callback takes), are documented in the headers.
Claude-Session: https://claude.ai/code/session_0178Lh3xS7wvbg3ge5jTuQU7
Co-authored-by: Claude <noreply@anthropic.com>
A decoded signal is added to the history on the radio worker thread,
while the receiver and info scenes read, rebuild and delete from the
same history on the app thread, without a lock.
The visible result, with "Delete old signals when memory is full" on:
open the oldest signal, let a new one arrive, press Send. The open item
has been deleted and the info screen still shows it, but Send transmits
the signal that moved into its slot, and the screen then redraws with
that one.
- Guard the history with a mutex, held by the add-to-history callback,
the list rebuild, Hold Right delete, the info screen's lookups and the
status bar update. It is never held across a radio stop.
- Keep the open item when old signals are dropped: the next oldest goes
instead.
- Re-read the chosen index under the lock and bound-check it on the info
screen. Look the signal up under the lock, but transmit outside it.
The new fields go at the end of struct SubGhz, so plugin offsets stay put.
Claude-Session: https://claude.ai/code/session_0178Lh3xS7wvbg3ge5jTuQU7
Co-authored-by: Claude <noreply@anthropic.com>
The draw callback kept strlen() in a uint8_t and copied the text into a
VLA of that size, then inserted the cursor and the "..." marker in place.
Every redraw with the cursor shown wrote 1 to 4 bytes past the VLA, on
the GUI thread's stack. A text of 256 characters or more also read as
its length modulo 256: the field looked empty or cut short, and the
cursor was clamped there, so typing went in at the wrong position.
Keep the length in a size_t and copy only a window around the cursor,
at most 127 characters on each side, into a buffer sized for the cursor
and the ellipsis.
Claude-Session: https://claude.ai/code/session_0178Lh3xS7wvbg3ge5jTuQU7
Co-authored-by: Claude <noreply@anthropic.com>
* BadUSB: add native Ducky language layouts
Add the native .kl layout loader and DUCKY_LANG script command. This feature-only commit uses the existing default keyboard layout and does not change its persistence.
* BadUSB: register DUCKY_LANG command
Register the per-script DUCKY_LANG command in the BadUSB command table.
* BadUSB: load native layout for each script
Add DUCKY_LANG execution, per-script layout state, and ASCII-safe HID string mapping. Existing persistent default layout remains unchanged.
* BadUSB: pass selected layout into script
Pass the existing selected keyboard layout into BadUsbScript at open; this does not alter layout persistence.
* BadUSB: retain default layout for script reset
Keep the existing selected layout as the per-script reset mapping for DUCKY_LANG.
* BadUSB: load native .kl layouts
Load validated 095E native keyboard maps for DUCKY_LANG, with safe en-US fallback and explicit ASCII limitation.
* BadUSB: pass selected layout to script runner
Pass the existing selected keyboard layout through the work scene to the script runner for DUCKY_LANG.
* Fix: remove nested layout loader path
Remove the accidental nested helper path before adding the source at its proper location.
* BadUSB: add native .kl layout loader
Add the DUCKY_LANG loader under the existing BadUSB helpers directory.
Use the shared EM4305 request builder so Gallagher writes consume encoded bits 0 through 95 instead of 1 through 96. Add a regression that compares all three data words with the equivalent T5577 frame.
Assisted-by: Codex (GPT-5) <noreply@openai.com>
The CLI checks the result of subghz_devices_begin() since #1171, but the
internal CC1101 has no begin hook and subghz_devices_begin() returned false
for any device without one. Every CLI rx/tx on device 0 stopped at
"Device 0 failed to start", and the failure path shut the radio down.
A device with no begin hook has nothing to start, so starting it succeeds.
The external module still reports its real self-test result.
Fixes#1215