Opened 6 years ago
Closed 6 years ago
#103 closed defect (fixed)
libc: strcpy and strncpy do not check if the strings overlap
| Reported by: | Lukáš Zaoral | Owned by: | mornfall |
|---|---|---|---|
| Priority: | major | Milestone: | 4.4 |
| Component: | DiOS | Keywords: | |
| Cc: | kdudka@…, jamartis@…, lzaoral@… |
Description
Hello,
the implementations of strcpy and strncpy should check, that the memory areas do overlap (like the implementation of memcpy does). At the moment, the following programs are mistakenly verified as correct. Thanks.
a) strcpy:
#include <string.h>
int main(void)
{
char str[] = "test";
strcpy(str, str + 1);
}
b) strncpy:
#include <string.h>
int main(void)
{
char str[] = "test";
strncpy(str, str + 1, 2);
}
Change History (2)
comment:1 Changed 6 years ago by
| Owner: | set to mornfall |
|---|---|
| Status: | new → accepted |
comment:2 Changed 6 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
Note: See
TracTickets for help on using
tickets.
Fixed in next.