fix: the telink b91 platform provides a custom decla... in string.h#1119
fix: the telink b91 platform provides a custom decla... in string.h#1119orbisai0security wants to merge 3 commits into
Conversation
Automated security fix generated by Orbis Security AI
There was a problem hiding this comment.
Code Review
This pull request removes the strcpy declaration from the Telink B91 string header to mitigate buffer overflow risks. Review feedback points out that strcat remains in the header and poses similar security concerns, and it advises that the suggested alternative, strncpy, requires manual null-termination to ensure safety.
| int strcmp(const char *_s1, const char *_s2); | ||
| int strcoll(const char *_s1, const char *_s2); | ||
| char * strcpy(char *_s1, const char *_s2); | ||
| /* strcpy() removed: use strncpy() with explicit buffer length to prevent buffer overflow */ |
There was a problem hiding this comment.
While removing strcpy is a positive step for security, this fix is incomplete. The strcat function (line 66) is still present in the header and poses the same buffer overflow risks (CWE-120) as strcpy. To fully address the security concerns mentioned in the PR description, strcat should also be removed or deprecated in favor of strncat.\n\nAdditionally, the suggestion to use strncpy should be accompanied by a warning that it does not guarantee null-termination if the source string is longer than the destination buffer. A safer pattern is to use strncpy followed by manual null-termination of the last byte.
/* strcpy() removed: use strncpy() with destination buffer size and manual null-termination */There was a problem hiding this comment.
@orbisai0security can you address code review comments?
|
✅ Changes Applied I've updated the code based on your feedback: The code review (by @gemini-code-assist) correctly identified that Files modified:
The changes have been pushed to this PR branch. Please review! |
|
✅ Review Feedback Addressed I've automatically addressed 1 review comment(s): The file already has Files modified:
The changes have been pushed to this PR branch. Please review! |
Summary
Fix critical severity security issue in
third_party/telink/b91/common/string.h.Vulnerability
V-001third_party/telink/b91/common/string.h:70Description: The Telink B91 platform provides a custom declaration of strcpy() in third_party/telink/b91/common/string.h at line 70. This function performs no bounds checking on the destination buffer. Any call site in the firmware that passes attacker-influenced data — such as strings from Thread network packets, UART input, or commissioning data — to this strcpy() without first validating the source string length against the destination buffer size is vulnerable to a classic stack or heap buffer overflow. The strcpy() function copies bytes from source to destination until a null terminator is encountered, with no mechanism to stop at the destination buffer boundary.
Changes
third_party/telink/b91/common/string.hVerification
Automated security fix by OrbisAI Security