fix: prevent panic in AesDecoder for sub-block-size records - #44
Open
JarrenMorris wants to merge 1 commit into
Open
fix: prevent panic in AesDecoder for sub-block-size records#44JarrenMorris wants to merge 1 commit into
JarrenMorris wants to merge 1 commit into
Conversation
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
force-pushed
the
fix/waypoint-aes-decoder-panic
branch
from
July 17, 2026 00:33
f2a6f7f to
06cf174
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).