Skip to content

Commit 2041cc6

Browse files
don't copy data into attr if size too big
1 parent 0155bce commit 2041cc6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,20 +1150,19 @@ uint8_t GattServer::atts_read_cb(
11501150

11511151
/* if new data provided copy into the attribute value buffer */
11521152
if (read_auth_params.data) {
1153-
11541153
if (read_auth_params.len > pAttr->maxLen) {
11551154
tr_error("Read authorisation callback set length larger than maximum attribute length, "
11561155
"cannot copy data");
11571156
err = ATT_ERR_UNLIKELY;
1158-
}
1159-
1160-
memcpy(pAttr->pValue, read_auth_params.data, read_auth_params.len);
1161-
*pAttr->pLen = read_auth_params.len;
1157+
} else {
1158+
memcpy(pAttr->pValue, read_auth_params.data, read_auth_params.len);
1159+
*pAttr->pLen = read_auth_params.len;
11621160

1163-
if (read_auth_params.len < offset) {
1164-
tr_warning("Read authorisation callback shortened data beyond current offset, "
1165-
"current read will fail");
1166-
err = ATT_ERR_OFFSET;
1161+
if (read_auth_params.len < offset) {
1162+
tr_warning("Read authorisation callback shortened data beyond current offset, "
1163+
"current read will fail");
1164+
err = ATT_ERR_OFFSET;
1165+
}
11671166
}
11681167
}
11691168
}

0 commit comments

Comments
 (0)