Opened 6 months ago

Closed 6 months 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@…


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 months ago by mornfall

Owner: set to mornfall
Status: newaccepted

comment:2 Changed 6 months ago by mornfall

Resolution: fixed
Status: acceptedclosed

Fixed in next.

Note: See TracTickets for help on using tickets.