Used correctly, the functions from the ``++<cstring>++`` library are safe and reliable. Unfortunately, they are easily misused, and can read or write beyond the end of defined buffer, resulting in undefined behavior. 


Therefore this rule flags all uses of the following methods, which should be avoided, in favor of functions from {cpp}'s new "safe string" library, ``++<string>++``: ``++strcpy++``, ``++strcmp++``, ``++strcat++``, ``++strchr++``, ``++strspn++``, ``++strcspn++``, ``++strpbrk++``, ``++strrchr++``, ``++strstr++``, ``++strtok++``, and ``++strlen++``.


== Noncompliant Code Example

----
#include <cstring>

void fn ( const char_t * pChar ) 
{ 
  char_t array [ 10 ];
  strcpy ( array, pChar ); // Noncompliant 
}
----


== Compliant Solution

----
#include <string>

void fn ( std::string str ) 
{ 
  int len = 10;
  char_t array [ len ];
  str.copy(array, len, 0);
}
----


== See

* MISRA {cpp}:2008, 18-0-5
* http://cwe.mitre.org/data/definitions/120[MITRE, CWE-120] - Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
* https://www.sans.org/top25-software-errors/#cat2[SANS Top 25] - Risky Resource Management

