summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-16 02:47:21 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-16 02:47:21 (GMT)
commit9019934c64c723e0f09e5cfe30e87d44ee116391 (patch)
treeeffd2de1447d5cd1b7e558c2c80be1feb84eb244 /win32/win32.c
parent12cccce6f676e82c80af31c1b8616c34c5fa8559 (diff)
win32.c: memcpy instead of strlcpy
* win32/win32.c (cmdglob): memcpy the exact size instead of strlcpy with +1. * win32/win32.c (w32_cmdvector): ditto, with NUL-terminating. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 385bda6..19513ab 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1566,7 +1566,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail, UINT cp, rb_encoding *e
if (patt->len >= PATH_MAX)
if (!(buf = malloc(patt->len + 1))) return 0;
- strlcpy(buf, patt->str, patt->len + 1);
+ memcpy(buf, patt->str, patt->len);
buf[patt->len] = '\0';
translate_char(buf, '\\', '/', cp);
status = ruby_brace_glob_with_enc(buf, 0, insert, (VALUE)&tail, enc);
@@ -1864,7 +1864,8 @@ w32_cmdvector(const WCHAR *cmd, char ***vec, UINT cp, rb_encoding *enc)
cptr = buffer + (elements+1) * sizeof(char *);
while ((curr = cmdhead) != 0) {
- strlcpy(cptr, curr->str, curr->len + 1);
+ memcpy(cptr, curr->str, curr->len);
+ cptr[curr->len] = '\0';
*vptr++ = cptr;
cptr += curr->len + 1;
cmdhead = curr->next;