Skip to content

Commit 3a8190a

Browse files
joerchancarlescufi
authored andcommitted
Bluetooth: SDP: Check len is not zero before accessing data pointer
Check len is not zero before accessing data pointer, the len variable is not checked before this point so cannot be trusted to not be zero. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
1 parent 7abc68d commit 3a8190a

File tree

1 file changed

+8
-0
lines changed
  • subsys/bluetooth/host

1 file changed

+8
-0
lines changed

subsys/bluetooth/host/sdp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,10 @@ static ssize_t sdp_get_attr_value_len(const uint8_t *data, size_t len)
21382138

21392139
BT_DBG("Attr val DTD 0x%02x", data[0]);
21402140

2141+
if (len < 1) {
2142+
goto err;
2143+
}
2144+
21412145
switch (data[0]) {
21422146
case BT_SDP_DATA_NIL:
21432147
case BT_SDP_BOOL:
@@ -2174,6 +2178,10 @@ static ssize_t sdp_get_attr_value_len(const uint8_t *data, size_t len)
21742178
BT_ERR("Unknown DTD 0x%02x", data[0]);
21752179
return -EINVAL;
21762180
}
2181+
err:
2182+
BT_ERR("Too short buffer length %zu", len);
2183+
return -EMSGSIZE;
2184+
21772185
}
21782186

21792187
/* Type holding UUID item and related to it specific information. */

0 commit comments

Comments
 (0)