Fix a bug in bluedroid when multiple SDP records are created (IDFGH-9219) #10607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Definition of the bug fixed by this PR
When creating multiple SDP records using the
esp_sdp_create_record()
function, the first call raises theESP_SDP_CREATE_RECORD_COMP_EVT
event with an status ofESP_SDP_SUCCESS
, as expected.However, the following calls to register other SDP records generate events where the
status
and thehandle
parameters of theesp_sdp_cb_param_t->create_record
struct have the same value, so the status is not considered a success and SDP records are not actually created, making it impossible to define more than one SDP record.This happens because those values are set in the function
bta_sdp_create_record()
, where atBTA_SDP
union is declared and two of its possible values are written at the same time (status
andhandle
).For reference, this was the
tBTA_SDP
definition:And this is the relevant code of the
bta_sdp_create_record()
function where the status was overwritten:How the bug was fixed
This PR fixes this situation by creating a
tBTA_SDP_CREATE_RECORD_USER
struct with the two required values (mimicking the already definedtBTA_SDP_SEARCH_COMP
struct), so setting the SDP recordhandle
doesn't overwrite thestatus
value.