Unified · Split
| @@ -1636,7 +1636,7 @@ PUB_FUNC char *tcc_default_target(TCCState *s, const char *default_file) · 1635 unmodified lines | ||
| 1636 | 1636 | && *ext) |
| 1637 | 1637 | strcpy(ext, ".o"); |
| 1638 | 1638 | else |
| 1639 | − pstrcpy(buf, sizeof(buf), "a.out"); | |
| 1639 | + strcpy(buf, "a.out"); | |
| 1640 | 1640 | |
| 1641 | 1641 | return tcc_strdup(buf); |
| 1642 | 1642 | } |
| @@ -2992,20 +2992,6 @@ static int ld_next(TCCState *s1, char *name, int name_size) · 2991 unmodified lines | ||
| 2992 | 2992 | return c; |
| 2993 | 2993 | } |
| 2994 | 2994 | |
| 2995 | −/* | |
| 2996 | − * Extract the file name from the library name | |
| 2997 | − * | |
| 2998 | − * /!\ No test on filename capacity, be careful | |
| 2999 | − */ | |
| 3000 | −static void libname_to_filename(TCCState *s1, const char libname[], char filename[]) | |
| 3001 | −{ | |
| 3002 | − if (!s1->static_link) { | |
| 3003 | − sprintf(filename, "lib%s.so", libname); | |
| 3004 | − } else { | |
| 3005 | − sprintf(filename, "lib%s.a", libname); | |
| 3006 | − } | |
| 3007 | −} | |
| 3008 | − | |
| 3009 | 2995 | static int ld_add_file(TCCState *s1, const char filename[]) |
| 3010 | 2996 | { |
| 3011 | 2997 | int ret; |
| @@ -3052,8 +3038,12 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 40 unmodified lines | ||
| 3052 | 3038 | ret = -1; |
| 3053 | 3039 | goto lib_parse_error; |
| 3054 | 3040 | } |
| 3055 | − strcpy(libname, &filename[1]); | |
| 3056 | − libname_to_filename(s1, libname, filename); | |
| 3041 | + pstrcpy(libname, sizeof libname, &filename[1]); | |
| 3042 | + if (s1->static_link) { | |
| 3043 | + snprintf(filename, sizeof filename, "lib%s.a", libname); | |
| 3044 | + } else { | |
| 3045 | + snprintf(filename, sizeof filename, "lib%s.so", libname); | |
| 3046 | + } | |
| 3057 | 3047 | } else if (t != LD_TOK_NAME) { |
| 3058 | 3048 | tcc_error_noabort("filename expected"); |
| 3059 | 3049 | ret = -1; |
| @@ -5580,7 +5580,7 @@ ST_FUNC void gen_inline_functions(void) · 5579 unmodified lines | ||
| 5580 | 5580 | str = fn->token_str; |
| 5581 | 5581 | fn->sym = NULL; |
| 5582 | 5582 | if (file) |
| 5583 | − strcpy(file->filename, fn->filename); | |
| 5583 | + pstrcpy(file->filename, sizeof file->filename, fn->filename); | |
| 5584 | 5584 | sym->r = VT_SYM | VT_CONST; |
| 5585 | 5585 | sym->type.t &= ~VT_INLINE; |
| 5586 | 5586 | |
| @@ -663,7 +663,7 @@ static int pe_write(struct pe_info *pe) · 662 unmodified lines | ||
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | − strcpy((char*)psh->Name, sh_name); | |
| 666 | + pstrcpy((char*)psh->Name, sizeof psh->Name, sh_name); | |
| 667 | 667 | |
| 668 | 668 | psh->Characteristics = pe_sec_flags[si->cls]; |
| 669 | 669 | psh->VirtualAddress = addr; |
| @@ -933,7 +933,7 @@ static void pe_build_exports(struct pe_info *pe) · 263 unmodified lines | ||
| 933 | 933 | |
| 934 | 934 | #if 1 |
| 935 | 935 | /* automatically write exports to <output-filename>.def */ |
| 936 | − strcpy(buf, pe->filename); | |
| 936 | + pstrcpy(buf, sizeof buf, pe->filename); | |
| 937 | 937 | strcpy(tcc_fileextension(buf), ".def"); |
| 938 | 938 | op = fopen(buf, "w"); |
| 939 | 939 | if (NULL == op) { |
| @@ -1598,7 +1598,7 @@ static int pe_load_def(TCCState *s1, FILE *fp) · 658 unmodified lines | ||
| 1598 | 1598 | case 0: |
| 1599 | 1599 | if (0 != strnicmp(p, "LIBRARY", 7)) |
| 1600 | 1600 | goto quit; |
| 1601 | − strcpy(dllname, trimfront(p+7)); | |
| 1601 | + pstrcpy(dllname, sizeof dllname, trimfront(p+7)); | |
| 1602 | 1602 | ++state; |
| 1603 | 1603 | continue; |
| 1604 | 1604 | |