Skip to content

Commit 558ada2

Browse files
author
Yasuki Okumura
committed
Add a validation for Advertising Data. Lengh should not be less than 1.
1 parent 4ae819d commit 558ada2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

adv.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ func (a *Advertisement) unmarshall(b []byte) error {
9393
return errors.New("invalid advertise data")
9494
}
9595
l, t := b[0], b[1]
96-
if len(b) < int(1+l) {
96+
if int(l) < 1 || len(b) < int(1+l) {
9797
return errors.New("invalid advertise data")
9898
}
99+
100+
log.Printf("len(b)[ %d ], int(1+l)[%d]", len(b), int(1+l))
101+
99102
d := b[2 : 1+l]
100103
switch t {
101104
case typeFlags:
@@ -131,7 +134,7 @@ func (a *Advertisement) unmarshall(b []byte) error {
131134
// case typeServiceData32,
132135
// case typeServiceData128:
133136
default:
134-
log.Printf("DATA: [ % X ]", d)
137+
log.Printf("DATAAAAAA: [ % X ]", d)
135138
}
136139
b = b[1+l:]
137140
}

0 commit comments

Comments
 (0)