Bluetooth: Fixed null byte check in DIS UDI
Due to sizeof('\0') evaluating to 4 bytes instead of 1: - Each UDI field had 4 instead of 1 'zero byte' appended (as specified by BLE spec). - Any field of length 4 was being skipped entirely. Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
This commit is contained in:
parent
89a80525c8
commit
905aed99fa
1 changed files with 2 additions and 2 deletions
|
@ -179,7 +179,7 @@ static ssize_t read_system_id(struct bt_conn *conn, const struct bt_gatt_attr *a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_BT_DIS_UDI
|
#if CONFIG_BT_DIS_UDI
|
||||||
#define DIS_STR_SIZE(x) ((x[0]) != '\0' ? strlen(x) + sizeof('\0') : 0)
|
#define DIS_STR_SIZE(x) ((x[0]) != '\0' ? strlen(x) + 1 : 0)
|
||||||
#define BT_DIS_UDI_FLAG_LABEL (!!BT_DIS_UDI_LABEL_STR_REF[0])
|
#define BT_DIS_UDI_FLAG_LABEL (!!BT_DIS_UDI_LABEL_STR_REF[0])
|
||||||
#define BT_DIS_UDI_FLAG_DI (!!BT_DIS_UDI_DI_STR_REF[0])
|
#define BT_DIS_UDI_FLAG_DI (!!BT_DIS_UDI_DI_STR_REF[0])
|
||||||
#define BT_DIS_UDI_FLAG_ISSUER (!!BT_DIS_UDI_ISSUER_STR_REF[0])
|
#define BT_DIS_UDI_FLAG_ISSUER (!!BT_DIS_UDI_ISSUER_STR_REF[0])
|
||||||
|
@ -196,7 +196,7 @@ static void read_udi_subval(const char *str, uint16_t val_len, char *buf, uint16
|
||||||
uint16_t *index, uint16_t len, uint16_t offset)
|
uint16_t *index, uint16_t len, uint16_t offset)
|
||||||
{
|
{
|
||||||
/* String should not be with included null-terminator if empty */
|
/* String should not be with included null-terminator if empty */
|
||||||
if (val_len == sizeof('\0')) {
|
if (val_len == sizeof("")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue