File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1692,6 +1692,10 @@ class GattCharacteristic {
1692
1692
* @note The params->len parameter initially contains the maximum length of
1693
1693
* data that can be returned. Set it to the length of your data but it must
1694
1694
* not be larger than the original value.
1695
+ *
1696
+ * @note You must also take into account the offset provided in params->offset.
1697
+ * The params->len you provide must be larger then the offset as the read operation
1698
+ * will attempt to read at that offset.
1695
1699
*/
1696
1700
GattAuthCallbackReply_t authorizeRead (GattReadAuthCallbackParams *params)
1697
1701
{
Original file line number Diff line number Diff line change @@ -1148,8 +1148,9 @@ uint8_t GattServer::atts_read_cb(
1148
1148
1149
1149
/* if new data provided copy into the attribute value buffer */
1150
1150
if (read_auth_params.data ) {
1151
- if (read_auth_params.offset + read_auth_params.len > pAttr->maxLen ) {
1152
- tr_error (" Read authorisation callback set length larger than maximum attribute length. Cannot copy data" );
1151
+ if (read_auth_params.len > pAttr->maxLen || offset >= read_auth_params.len ) {
1152
+ tr_error (" Read authorisation callback set length larger than maximum attribute length "
1153
+ " or current offset is beyond new length. Cannot copy data" );
1153
1154
1154
1155
GattReadCallbackParams read_params = {
1155
1156
connId,
@@ -1164,7 +1165,7 @@ uint8_t GattServer::atts_read_cb(
1164
1165
return ATT_ERR_UNLIKELY;
1165
1166
}
1166
1167
1167
- memcpy (pAttr->pValue + read_auth_params. offset , read_auth_params.data , read_auth_params.len );
1168
+ memcpy (pAttr->pValue , read_auth_params.data , read_auth_params.len );
1168
1169
*pAttr->pLen = read_auth_params.len ;
1169
1170
}
1170
1171
}
You can’t perform that action at this time.
0 commit comments