Skip to content

[Coverity CID: 220426] Out-of-bounds access in tests/lib/c_lib/src/main.c #33810

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/169144afa1826511ee6ec3f53d590b2c0d39d3d4/tests/lib/c_lib/src/main.c#L536

Category: Memory - corruptions
Function: test_memstr
Component: Tests
CID: 220426

Details:

memcpy(&arr[i], num, 0);

530         zassert_is_null(memchr(str, 'a', 0), "memchr 0 error");
531         zassert_not_null(memchr(str, 'e', 10), "memchr serach e");
532         zassert_is_null(memchr(str, 'e', 1), "memchr e error");
533    
534         for (i = 0; i < 20; i++) {
535             for (j = 0; j < 20; j++) {
>>>     CID 220426:  Memory - corruptions  (OVERRUN)
>>>     Calling "memcpy" with "&arr[i]" and "0U" is suspicious because the function call may access "arr" at byte "i + 18446744073709551615U". [Note: The source code implementation of the function has been overridden by a builtin model.]
536                 memcpy(&arr[i], num, 0);
537                 ret = memcmp(&num[j], &arr[i], 0);
538                 zassert_true((ret == 0), "memcpy failed");
539                 memcpy(&arr[i], &num[j], 1);
540                 ret = memcmp(&num[j], &arr[i], 1);
541                 zassert_true((ret == 0), "memcpy failed");

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v29271/p12996

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

Metadata

Metadata

Assignees

Labels

CoverityA Coverity detected issue or its fixbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions