Skip to content

Bluetooth: Classic: HFP_AG: Avoid potential array out-of-bounds access issues. #90774

Closed
@lylezhu2012

Description

@lylezhu2012

Describe the bug

At line 283 of the function get_new_call() in the file zephyr/subsys/bluetooth/host/classic/hfp_ag.c, when accessing a fixed-length data, it is not considered whether the array will cross the boundary.

strcpy(call->number, number);

However, this issue is not possible at present because all callers of the get_new_call() function will confirm that the length of number is less than the buffer size before calling the function get_new_call().

len = strlen(number);
if (len == 0) {
return -ENOTSUP;
}
if (len > CONFIG_BT_HFP_AG_PHONE_NUMBER_MAX_LEN) {
return -ENAMETOOLONG;
}

len = strlen(number);
if ((len == 0) || (len > CONFIG_BT_HFP_AG_PHONE_NUMBER_MAX_LEN)) {
return -EINVAL;
}

To avoid potential array out-of-bounds access issues and easy to maintain, improve it.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions