Skip to content

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

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/21d1ad3762302b3e461953df59430c77e0709274/tests/lib/c_lib/src/main.c#L557

Category: Memory - corruptions
Function: test_memcpy
Component: Tests
CID: 236074

Details:

zassert_equal(memcpy(mem_dest_tmp, mem_src_tmp, 10),

551     
552      /* restore the environment */
553      memset(mem_dest_byte, '\0', sizeof(mem_dest));
554      /* verify when dest and src are all in not word aligned */
555      mem_dest_tmp = mem_dest_byte + sizeof(uintptr_t) - 1;
556      mem_src_tmp = mem_src_byte + sizeof(uintptr_t) - 1;
>>>     CID 236074:  Memory - corruptions  (OVERRUN)
>>>     Overrunning buffer pointed to by "mem_dest_tmp" of 12 bytes by passing it to a function which accesses it at byte offset 12 using argument "10U". [Note: The source code implementation of the function has been overridden by a builtin model.]
557      zassert_equal(memcpy(mem_dest_tmp, mem_src_tmp, 10),
558              mem_dest_tmp, "memcpy error");
559      zassert_equal(memcmp(mem_dest_tmp, mem_src_tmp, 10),
560              0, "memcpy failed");
561     
562      /* restore the environment */

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

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions