LICENSE MIT
Nname() is used to concatenate two strings and is frequently used with
the first string being the name of the executable perhaps with a full
path. The static buffer specified is too small for a full path and
there was no protection against writing beyond the end of it.
static char *
NName(char *a1, char *a2)
{
- static char tbuffer[80];
+ static char tbuffer[300];
if (strlen(a1) == 0) {
- return "";
+ return "";
} else {
- strcpy(tbuffer, a1);
- strcat(tbuffer, a2);
- return tbuffer;
+ strncpy(tbuffer, a1, sizeof(tbuffer));
+ strncat(tbuffer, a2, sizeof(tbuffer));
+ tbuffer[sizeof(tbuffer)-1]='\0';
+ return tbuffer;
}
}