[前][次][番号順一覧][スレッド一覧]

ruby-changes:45564

From: nobu <ko1@a...>
Date: Thu, 16 Feb 2017 11:47:27 +0900 (JST)
Subject: [ruby-changes:45564] nobu:r57637 (trunk): win32.c: memcpy instead of strlcpy

nobu	2017-02-16 11:47:21 +0900 (Thu, 16 Feb 2017)

  New Revision: 57637

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57637

  Log:
    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.

  Modified files:
    trunk/win32/win32.c
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 57636)
+++ win32/win32.c	(revision 57637)
@@ -1566,7 +1566,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLin https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1566
     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 *** https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L1864
     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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]