mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
Prevent strzcpy access out-of-bound
When parameter 'len' is smaller or equal to 0, do not null-terminate. BUG=chrome-os-partner:11041 TEST=Build success. Change-Id: Ia5267e7d31e3ade8828ba0bc2d68405b4cd236be Reviewed-on: https://gerrit.chromium.org/gerrit/26640 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
@@ -184,6 +184,8 @@ void *memmove(void *dest, const void *src, int len)
|
||||
char *strzcpy(char *dest, const char *src, int len)
|
||||
{
|
||||
char *d = dest;
|
||||
if (len <= 0)
|
||||
return dest;
|
||||
while (len > 1 && *src) {
|
||||
*(d++) = *(src++);
|
||||
len--;
|
||||
|
||||
Reference in New Issue
Block a user