summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 01:29:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 01:29:17 +0000
commit22cde7b682328ba195ce0ee214edb6c2feb81b23 (patch)
tree7873fbf3dad59cb2042390c1c2dbfe90d5b6e647 /ruby.c
parentea9628c3bc700c5162a6298b79d2b8cd7a334fea (diff)
* dir.c, dln.c, parse.y, re.c, ruby.c, sprintf.c, strftime.c,
string.c, util.c, variable.c: use strlcpy, memcpy and snprintf instead of strcpy, strncpy and sprintf. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ruby.c b/ruby.c
index 49c33d3167..99f1f1984f 100644
--- a/ruby.c
+++ b/ruby.c
@@ -379,7 +379,7 @@ ruby_init_loadpath_safe(int safe_level)
}
}
else {
- strcpy(libpath, ".");
+ strlcpy(libpath, ".", sizeof(libpath));
p = libpath + 1;
}
@@ -522,15 +522,16 @@ moreswitches(const char *s, struct cmdline_options *opt, int envopt)
char **argv, *p;
const char *ap = 0;
VALUE argstr, argary;
+ int len;
while (ISSPACE(*s)) s++;
if (!*s) return;
- argstr = rb_str_tmp_new(strlen(s) + 2);
+ argstr = rb_str_tmp_new((len = strlen(s)) + 2);
argary = rb_str_tmp_new(0);
p = RSTRING_PTR(argstr);
*p++ = ' ';
- strcpy(p, s);
+ memcpy(p, s, len + 1);
ap = 0;
rb_str_cat(argary, (char *)&ap, sizeof(ap));
while (*p) {