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

Owner: set to mornfall
Status: newaccepted

comment:2 Changed 11 months ago by mornfall

Resolution: fixed
Status: acceptedclosed

Fixed in next.

Note: See TracTickets for help on using tickets.