safety: replace occurrences of strcpy by pstrcpy

This commit is contained in:
grischka
2013-01-31 11:29:45 +01:00
parent 370547a550
commit 2f6b8469cc
4 changed files with 11 additions and 21 deletions

View File

@ -2992,20 +2992,6 @@ static int ld_next(TCCState *s1, char *name, int name_size)
return c;
}
/*
* Extract the file name from the library name
*
* /!\ No test on filename capacity, be careful
*/
static void libname_to_filename(TCCState *s1, const char libname[], char filename[])
{
if (!s1->static_link) {
sprintf(filename, "lib%s.so", libname);
} else {
sprintf(filename, "lib%s.a", libname);
}
}
static int ld_add_file(TCCState *s1, const char filename[])
{
int ret;
@ -3052,8 +3038,12 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
ret = -1;
goto lib_parse_error;
}
strcpy(libname, &filename[1]);
libname_to_filename(s1, libname, filename);
pstrcpy(libname, sizeof libname, &filename[1]);
if (s1->static_link) {
snprintf(filename, sizeof filename, "lib%s.a", libname);
} else {
snprintf(filename, sizeof filename, "lib%s.so", libname);
}
} else if (t != LD_TOK_NAME) {
tcc_error_noabort("filename expected");
ret = -1;