bt: avoid unintended sign extension

In the case of a 4-byte length, shifting a value by 24 may cause
an unintended sign extension when converting from int to size_t.
Use a uint32_t variable instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Paolo Bonzini 2015-11-27 13:08:25 +01:00 committed by Michael Tokarev
parent 624533e5a5
commit e0df8f18f7

View File

@ -42,7 +42,7 @@ struct bt_l2cap_sdp_state_s {
static ssize_t sdp_datalen(const uint8_t **element, ssize_t *left)
{
size_t len = *(*element) ++ & SDP_DSIZE_MASK;
uint32_t len = *(*element) ++ & SDP_DSIZE_MASK;
if (!*left)
return -1;