Skip to content

fix: prevent panic in AesDecoder for sub-block-size records - #44

Open
JarrenMorris wants to merge 1 commit into
lvauvillier:masterfrom
JarrenMorris:fix/waypoint-aes-decoder-panic
Open

fix: prevent panic in AesDecoder for sub-block-size records#44
JarrenMorris wants to merge 1 commit into
lvauvillier:masterfrom
JarrenMorris:fix/waypoint-aes-decoder-panic

Conversation

@JarrenMorris

Copy link
Copy Markdown

Fixes #43

Records belonging to WaypointFeature (types 31, 32, 34-36, 38, 39) can have a ciphertext payload smaller than one AES block (16 bytes). AesDecoder::new previously called unwrap() on read_exact and indexed the buffer with buffer.len() - Aes256::block_size(), both of which panic when the buffer is shorter than 16 bytes. In WASM builds, these panics manifest as a RuntimeError: unreachable trap, causing records() and frames() to abort entirely for any log containing waypoint mission data.

Fix by handling read failures and small buffers gracefully: fall back to a zero IV when the ciphertext is shorter than one block, and return an empty decoder on read or key-init errors instead of panicking. Also harden new_from_slices to not unwrap.

Fixes parsing of Matrice 350 RTK (and other aircraft) waypoint mission logs (log version 14, FR_Standardization_Feature_Waypoint_3).

Records belonging to WaypointFeature (types 31, 32, 34-36, 38, 39)
can have a ciphertext payload smaller than one AES block (16 bytes).
AesDecoder::new previously called unwrap() on read_exact and indexed
the buffer with buffer.len() - Aes256::block_size(), both of which
panic when the buffer is shorter than 16 bytes. In WASM builds,
these panics manifest as a RuntimeError: unreachable trap, causing
records() and frames() to abort entirely for any log containing
waypoint mission data.

Fix by handling read failures and small buffers gracefully: fall back
to a zero IV when the ciphertext is shorter than one block, and
return an empty decoder on read or key-init errors instead of
panicking. Also harden new_from_slices to not unwrap.

Fixes parsing of Matrice 350 RTK (and other aircraft) waypoint
mission logs (log version 14, FR_Standardization_Feature_Waypoint_3).
saschaheim pushed a commit to saschaheim/dji-log-parser that referenced this pull request Jun 10, 2026
@JarrenMorris
JarrenMorris force-pushed the fix/waypoint-aes-decoder-panic branch from f2a6f7f to 06cf174 Compare July 17, 2026 00:33
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.

RuntimeError: unreachable in records() for v14 waypoint mission logs (Matrice 350 RTK)

1 participant