-
Notifications
You must be signed in to change notification settings - Fork 3
Update btrCore.c #39
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
base: develop
Are you sure you want to change the base?
Update btrCore.c #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,6 +70,7 @@ int b_rdk_logger_enabled = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| #define BTRCORE_REMOTE_OUI_LENGTH 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #define BTRCORE_AMAZON_OUI_LENGTH 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #define BTRCORE_GOOGLE_OUI_LENGTH 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #define BTRCORE_XBOX_GEN3_OUI_LENGTH 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| static char * BTRCORE_REMOTE_OUI_VALUES[] = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "20:44:41", //LC103 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -96,6 +97,13 @@ static char * BTRCORE_GOOGLE_OUI_VALUES[] = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| "CA:7B:25", //Stadia2TFX-0fa6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| static char* BTRCORE_XBOX_GEN3_OUI_VALUES[] = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "44:16:22", // Microsoft (Xbox Gen3) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "9C:AA:1B", // Microsoft (Xbox Gen3) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Local types */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| //TODO: Move to a private header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| typedef enum _enBTRCoreTaskOp { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -857,6 +865,24 @@ static BOOLEAN btrCore_IsLunaGamepad( | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| static BOOLEAN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| btrCore_IsXboxGen3Gamepad(char* pcAddress) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| unsigned char i; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pcAddress == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| BTRCORELOG_ERROR("Received NULL mac address\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| for (i = 0; BTRCORE_XBOX_GEN3_OUI_VALUES[i] != NULL; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!strncmp(pcAddress, BTRCORE_XBOX_GEN3_OUI_VALUES[i], BTRCORE_XBOX_GEN3_OUI_LENGTH)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| BTRCORELOG_DEBUG("Device OUI matches Xbox Gen3 gamepad\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return TRUE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| static BOOLEAN btrCore_IsDeviceRdkRcu( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| char * pcAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| unsigned short ui16Appearance | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -7113,6 +7139,19 @@ btrCore_BTDeviceStatusUpdateCb ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| strncpy(FoundDevice.pcDeviceName, apstBTDeviceInfo->pcName, BD_NAME_LEN); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| strncpy(FoundDevice.pcDeviceAddress, apstBTDeviceInfo->pcAddress, BD_NAME_LEN); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /* Xbox Gen3 exception: force immediate UI update with a temporary name */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (btrCore_IsDevNameSameAsAddress(&FoundDevice) && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| btrCore_IsXboxGen3Gamepad(FoundDevice.pcDeviceAddress)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| errno_t rc; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| rc = strcpy_s(FoundDevice.pcDeviceName,BD_NAME_LEN,"Xbox Wireless Controller"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coverity Issue - Array compared against 0Comparing an array to null is not useful: ""Xbox Wireless Controller" != NULL", since the test will always evaluate as true. Medium Impact, CWE-398 How to fixWas ""Xbox Wireless Controller"" formerly declared as a pointer? |
||||||||||||||||||||||||||||||||||||||||||||||||||
| ERR_CHK(rc); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| rc = strcpy_s(apstBTDeviceInfo->pcName,BD_NAME_LEN,"Xbox Wireless Controller"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7146
to
+7149
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| rc = strcpy_s(FoundDevice.pcDeviceName,BD_NAME_LEN,"Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| rc = strcpy_s(apstBTDeviceInfo->pcName,BD_NAME_LEN,"Xbox Wireless Controller"); | |
| rc = strcpy_s(FoundDevice.pcDeviceName, sizeof(FoundDevice.pcDeviceName), "Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| rc = strcpy_s(apstBTDeviceInfo->pcName, sizeof(apstBTDeviceInfo->pcName), "Xbox Wireless Controller"); |
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.
Coverity Issue - Array compared against 0
Comparing an array to null is not useful: ""Xbox Wireless Controller" != NULL", since the test will always evaluate as true.
Medium Impact, CWE-398
NO_EFFECT
How to fix
Was ""Xbox Wireless Controller"" formerly declared as a pointer?
Copilot
AI
Feb 10, 2026
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.
This change introduces new behavioral logic (Xbox Gen3 OUI detection that mutates pcName to force an immediate UI update), but the existing unit tests for btrCore_BTDeviceStatusUpdateCb don’t appear to exercise this branch. Please add a test case where deviceInfo.pcName initially equals deviceInfo.pcAddress and the address matches one of the new OUIs, and assert that the callback updates the name as expected.
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.
Coverity Issue - String not null terminated
Passing unterminated string "FoundDevice.pcDeviceAddress" to "fprintf", which expects a null-terminated string.
High Impact, CWE-170
STRING_NULL
Copilot
AI
Feb 10, 2026
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.
The indentation/bracing in the new Xbox Gen3 exception block is inconsistent with the surrounding code (mixed tab/space at the comment line and misaligned closing brace). Please reformat this block to match the file’s existing indentation so it’s easier to read and avoids diffs caused by whitespace-only changes later.
| /* Xbox Gen3 exception: force immediate UI update with a temporary name */ | |
| if (btrCore_IsDevNameSameAsAddress(&FoundDevice) && | |
| btrCore_IsXboxGen3Gamepad(FoundDevice.pcDeviceAddress)) { | |
| errno_t rc; | |
| rc = strcpy_s(FoundDevice.pcDeviceName,BD_NAME_LEN,"Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| rc = strcpy_s(apstBTDeviceInfo->pcName,BD_NAME_LEN,"Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| BTRCORELOG_INFO("Gen3 detected by OUI; forcing UI update with temporary name for %s\n",FoundDevice.pcDeviceAddress); | |
| } | |
| /* Xbox Gen3 exception: force immediate UI update with a temporary name */ | |
| if (btrCore_IsDevNameSameAsAddress(&FoundDevice) && | |
| btrCore_IsXboxGen3Gamepad(FoundDevice.pcDeviceAddress)) { | |
| errno_t rc; | |
| rc = strcpy_s(FoundDevice.pcDeviceName, BD_NAME_LEN, "Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| rc = strcpy_s(apstBTDeviceInfo->pcName, BD_NAME_LEN, "Xbox Wireless Controller"); | |
| ERR_CHK(rc); | |
| BTRCORELOG_INFO("Gen3 detected by OUI; forcing UI update with temporary name for %s\n", FoundDevice.pcDeviceAddress); | |
| } |
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.
PR description says this is for "Debug purpose for coverity", but the diff adds product behavior (new Xbox Gen3 OUI list + forcing device name updates). Please update the PR description to reflect the actual functional change and expected user impact, or gate this logic behind a debug/diagnostic flag if it’s intended to be temporary.