From 9019934c64c723e0f09e5cfe30e87d44ee116391 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 16 Feb 2017 02:47:21 +0000 Subject: 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 --- win32/win32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'win32/win32.c') diff --git a/win32/win32.c b/win32/win32.c index 385bda64c9..19513ab69d 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; -- cgit v1.2.3