diff options
Diffstat (limited to 'tccelf.c')
| -rw-r--r-- | tccelf.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -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; |
