Static Analysis Problem Type Reference

Misuse of strcpy/strcat string functions

Buffer overflow due to misuse of string function.

This diagnostic covers several usage errors related to string manipulation functions such as strcat and strcpy.

ID

Code Location

Description

1

Buffer overflow

The place where the string function was used

Example


#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    char buf[16];
    strcpy(buf, argv[0]); // unsafe
    printf("%s\n", buf);
    return 0;
}