Skip to content

Commit 30edb5e

Browse files
Thalleynashif
authored andcommitted
Bluetooth: Audio: VOCS add missing check for offset in writes
VOCS does not support the write long procedure, and thus should not accept any offset in write requests. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 04232fe commit 30edb5e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

subsys/bluetooth/audio/vocs.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ static ssize_t write_location(struct bt_conn *conn, const struct bt_gatt_attr *a
5353
struct bt_vocs_server *inst = attr->user_data;
5454
uint32_t old_location = inst->location;
5555

56+
if (offset) {
57+
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
58+
}
59+
5660
if (len != sizeof(inst->location)) {
5761
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
5862
}
@@ -91,6 +95,10 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att
9195
const struct bt_vocs_control *cp = buf;
9296
bool notify = false;
9397

98+
if (offset) {
99+
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
100+
}
101+
94102
if (!len || !buf) {
95103
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
96104
}
@@ -101,10 +109,6 @@ static ssize_t write_vocs_control(struct bt_conn *conn, const struct bt_gatt_att
101109
return BT_GATT_ERR(BT_VOCS_ERR_OP_NOT_SUPPORTED);
102110
}
103111

104-
if (offset) {
105-
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
106-
}
107-
108112
if (len != sizeof(struct bt_vocs_control)) {
109113
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
110114
}
@@ -160,6 +164,10 @@ static ssize_t write_output_desc(struct bt_conn *conn, const struct bt_gatt_attr
160164
{
161165
struct bt_vocs_server *inst = attr->user_data;
162166

167+
if (offset) {
168+
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
169+
}
170+
163171
if (len >= sizeof(inst->output_desc)) {
164172
BT_DBG("Output desc was clipped from length %u to %zu",
165173
len, sizeof(inst->output_desc) - 1);

0 commit comments

Comments
 (0)