-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Bluetooth: Tester: BTP MTU handling improvements #84301
base: main
Are you sure you want to change the base?
Conversation
tests/bluetooth/tester/src/btp.c
Outdated
struct btp_hdr hdr; | ||
}; | ||
uint8_t data[BTP_MTU]; /* includes btp header */ | ||
uint8_t rsp[BTP_MTU - sizeof(struct btp_hdr)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider defining a BTP_RSP_MTU
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSP has same MTU, it is just that we don't have (need) header in response buffer (since data from command header is used)
uint8_t status; | ||
uint16_t rsp_len = 0; | ||
uint16_t len; | ||
|
||
cmd = k_fifo_get(&cmds_queue, K_FOREVER); | ||
hdr = (struct btp_hdr *)cmd->data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have an
hdr = (struct btp_hdr *)cmd->data; | |
hdr = (struct btp_hdr *)cmd->data; | |
__ASSERT_NO_MSG(hdr->len <= BTP_DATA_MAX_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I'm not sure if this should be assert as this means we assert on invalid command, I'll make this runtime check and simply return error (like we do for unknown command
The commit message doesn't really make sense anymore since |
This may cause some compiler warnings due to flexible array being used in btp_hdr. Simply avoid it and do explicit pointer type cast where needed. Signed-off-by: Szymon Janc <[email protected]>
Make sure MTU is validated to avoid reading pass command buffer. Also make more explicit check in response length validation. Signed-off-by: Szymon Janc <[email protected]>
if (len > BTP_DATA_MAX_SIZE) { | ||
status = BTP_STATUS_FAILED; | ||
} else if (btp->index != hdr->index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, now I wonder if it's really need as we do have } else if ((btp->expect_len >= 0) && (btp->expect_len != len)) {
which I guess would already catch it?
This is not allowed by C11 and may cause issues if GNU extensions are disabled.