From 2f6b8469cc27c0679460a2b70a35f8ba830281fc Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 31 Jan 2013 11:29:45 +0100 Subject: safety: replace occurrences of strcpy by pstrcpy --- tccelf.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'tccelf.c') diff --git a/tccelf.c b/tccelf.c index 5582bc5..152c4fb 100644 --- a/tccelf.c +++ b/tccelf.c @@ -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; -- cgit v1.3.1