summaryrefslogtreecommitdiff
path: root/dir.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 /dir.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 'dir.c')
-rw-r--r--dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 9b502ef42f..31b752e7f9 100644
--- a/dir.c
+++ b/dir.c
@@ -1463,7 +1463,8 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
}
if (lbrace && rbrace) {
- char *buf = GLOB_ALLOC_N(char, strlen(s) + 1);
+ size_t len = strlen(s) + 1;
+ char *buf = GLOB_ALLOC_N(char, len);
long shift;
if (!buf) return -1;
@@ -1482,7 +1483,7 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
Inc(p, pend, enc);
}
memcpy(buf+shift, t, p-t);
- strcpy(buf+shift+(p-t), rbrace+1);
+ strlcpy(buf+shift+(p-t), rbrace+1, len-(shift+(p-t)));
status = ruby_brace_expand(buf, flags, func, arg, enc);
if (status) break;
}