Fix panic in DTX readEntry on truncated auxiliary data
Summary
Fixes a panic in readEntry() in dtxprimitivedictionary.go that occurs when the auxiliary payload is empty or shorter than expected.
Problem
The readEntry() function directly calls binary.LittleEndian.Uint32() without checking whether the input slice has at least 4 bytes. When the auxiliary payload is empty or truncated, this causes an out-of-range panic:
goroutine 3495138 [running]:
encoding/binary.littleEndian.Uint32(...)
/opt/homebrew/Cellar/go/1.24.5/libexec/src/encoding/binary/binary.go:91
github.com/danielpaulus/go-ios/ios/dtx_codec.readEntry(...)
.../dtxprimitivedictionary.go:181 +0x38c
Solution
-
readEntry()now returns an error instead of panicking - Added bounds checking before all slice accesses:
- Check for at least 4 bytes before reading the type
- Check for at least 8 bytes before reading uint32 values
- Check for at least 12 bytes before reading int64 values
- Check for sufficient bytes before reading variable-length data
-
DecodeAuxiliary()handles errors gracefully with warnings instead of crashing - Removed unused
isNSKeyedArchiverEncodedfunction
Test plan
- [x] Build succeeds
- [x] Existing functionality preserved for valid data
- [x] Graceful handling of truncated/empty auxiliary payloads
Fixes #646
🤖 Generated with Claude Code
@aa645508087 are you able to test this version and provide feedback?
@aluedeke Thanks for the fix! I’ll run verification on my side using multiple iPhones for a synchronized WDA stress test over an extended period. I’ll need about 1–2 days to complete the validation and will update you with the results.
@aluedeke Thanks for the fix! I’ve verified the patch by running six iOS devices in parallel with WDA for 24 hours, and there were no panics during the entire run. The issue looks fully resolved.
Great work!