aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorgrischka <grischka>2013-01-31 11:29:45 +0100
committergrischka <grischka>2013-01-31 13:23:19 +0100
commit2f6b8469cc27c0679460a2b70a35f8ba830281fc (patch)
treee5d8d10c8666dbfc0b7df912d307588f4eef8056 /tccelf.c
parent370547a550e73d91e95cac6145a7df7947025bb0 (diff)
downloadtinycc-2f6b8469cc27c0679460a2b70a35f8ba830281fc.tar.gz
tinycc-2f6b8469cc27c0679460a2b70a35f8ba830281fc.tar.bz2
safety: replace occurrences of strcpy by pstrcpy
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c22
1 files changed, 6 insertions, 16 deletions
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;