diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-08-07 16:23:31 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-08-07 16:23:31 -0700 |
| commit | 3b2b760ed3f67cd0e1400df50becaffb7a75a1cd (patch) | |
| tree | ee843fadf47c1c6b7409dbc14a323d8fb4dd2d25 /tools | |
| parent | d2be15423a7fc54f143c517ef6f5a2b1a6e17163 (diff) | |
| parent | 29381bc819bdb0602ef4005a7d01daf605310fce (diff) | |
| download | mruby-3b2b760ed3f67cd0e1400df50becaffb7a75a1cd.tar.gz mruby-3b2b760ed3f67cd0e1400df50becaffb7a75a1cd.zip | |
Merge pull request #1445 from cremno/no_strcpy_and_strcat
don't use str{cpy,cat} in mruby and mrbc
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/mrbc/mrbc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c index 79fcd2bdf..735b22b1d 100644 --- a/tools/mrbc/mrbc.c +++ b/tools/mrbc/mrbc.c @@ -51,15 +51,19 @@ usage(const char *name) static char * get_outfilename(mrb_state *mrb, char *infile, char *ext) { + size_t infilelen; + size_t extlen; char *outfile; char *p; - outfile = (char*)mrb_malloc(mrb, strlen(infile) + strlen(ext) + 1); - strcpy(outfile, infile); + infilelen = strlen(infile); + extlen = strlen(ext); + outfile = (char*)mrb_malloc(mrb, infilelen + extlen + 1); + memcpy(outfile, infile, infilelen + 1); if (*ext) { if ((p = strrchr(outfile, '.')) == NULL) - p = &outfile[strlen(outfile)]; - strcpy(p, ext); + p = outfile + infilelen; + memcpy(p, ext, extlen + 1); } return outfile; |
