Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid slice bounds out of range #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dki1110
Copy link

@dki1110 dki1110 commented May 17, 2020

Fixed the following panic when scaning.

panic: runtime error: slice bounds out of range [2:1]

goroutine 18803 [running]:
github.com/paypal/gatt.(*Advertisement).unmarshall(0x2711ef0, 0x2761160, 0xe, 0xe, 0x115b94, 0x2492018)
	/home/pi/.go/src/github.com/paypal/gatt/adv.go:99 +0x8c4
github.com/paypal/gatt.(*device).Init.func3(0x24599e0)
	/home/pi/.go/src/github.com/paypal/gatt/device_linux.go:97 +0x50
github.com/paypal/gatt/linux.(*HCI).handleAdvertisement(0x248e040, 0x2796b93, 0xc, 0xc)
	/home/pi/.go/src/github.com/paypal/gatt/linux/hci.go:262 +0x214
created by github.com/paypal/gatt/linux.(*HCI).handleLEMeta
	/home/pi/.go/src/github.com/paypal/gatt/linux/hci.go:359 +0x114

@@ -96,6 +96,9 @@ func (a *Advertisement) unmarshall(b []byte) error {
if len(b) < int(1+l) {
return errors.New("invalid advertise data")
}
if l <= 2 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be

if l < 2

else all advertisements are ignored.

Copy link

@p3ddd p3ddd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helpful

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.

3 participants