Skip to content

panic: runtime error: index out of range #646

@aa645508087

Description

@aa645508087

While communicating with an iOS device using go-ios, I occasionally encounter a panic caused by readEntry() in dtxprimitivedictionary.go.
The function directly calls binary.LittleEndian.Uint32() without checking whether auxBytes is at least 4 bytes long.
When the auxiliary payload happens to be empty or shorter than expected, this results in an out-of-range panic.

stacktrace:
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({0x12480ba0?, 0xc000d37940?, 0x112f5c20?})
/Users/frank.lin/go/pkg/mod/github.com/danielpaulus/go-ios@v1.0.182/ios/dtx_codec/dtxprimitivedictionary.go:181 +0x38c
github.com/danielpaulus/go-ios/ios/dtx_codec.DecodeAuxiliary({0x12480ba0, 0x0, 0x0})
/Users/frank.lin/go/pkg/mod/github.com/danielpaulus/go-ios@v1.0.182/ios/dtx_codec/dtxprimitivedictionary.go:146 +0xd7
github.com/danielpaulus/go-ios/ios/dtx_codec.ReadMessage({0x1139c820, 0xc005d972c0})
/Users/frank.lin/go/pkg/mod/github.com/danielpaulus/go-ios@v1.0.182/ios/dtx_codec/decoder.go:73 +0x4cd
github.com/danielpaulus/go-ios/ios/dtx_codec.reader(0xc0046a7e00)
/Users/frank.lin/go/pkg/mod/github.com/danielpaulus/go-ios@v1.0.182/ios/dtx_codec/connection.go:195 +0x1c5
created by github.com/danielpaulus/go-ios/ios/dtx_codec.newDtxConnection in goroutine 3495050
/Users/frank.lin/go/pkg/mod/github.com/danielpaulus/go-ios@v1.0.182/ios/dtx_codec/connection.go:181 +0x285

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions