ruby-changes:10287
From: yugui <ko1@a...>
Date: Wed, 28 Jan 2009 18:23:48 +0900 (JST)
Subject: [ruby-changes:10287] Ruby:r21832 (ruby_1_9_1): merges r21763 from trunk into ruby_1_9_1.
yugui 2009-01-28 18:22:54 +0900 (Wed, 28 Jan 2009) New Revision: 21832 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21832 Log: merges r21763 from trunk into ruby_1_9_1. * dir.c (join_path): use strlcat() to force link. * dir.c (glob_helper): no strcpy() is needed since len is known. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/dir.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 21831) +++ ruby_1_9_1/ChangeLog (revision 21832) @@ -1,3 +1,9 @@ +Sun Jan 25 09:09:29 2009 Nobuyoshi Nakada <nobu@r...> + + * dir.c (join_path): use strlcat() to force link. + + * dir.c (glob_helper): no strcpy() is needed since len is known. + Sat Jan 24 08:22:35 2009 Nobuyoshi Nakada <nobu@r...> * lib/mkmf.rb (configuration): tools under the top source Index: ruby_1_9_1/dir.c =================================================================== --- ruby_1_9_1/dir.c (revision 21831) +++ ruby_1_9_1/dir.c (revision 21832) @@ -1112,15 +1112,16 @@ join_path(const char *path, int dirsep, const char *name) { long len = strlen(path); - char *buf = GLOB_ALLOC_N(char, len+strlen(name)+(dirsep?1:0)+1); + long len2 = strlen(name)+(dirsep?1:0)+1; + char *buf = GLOB_ALLOC_N(char, len+len2); if (!buf) return 0; memcpy(buf, path, len); if (dirsep) { - strcpy(buf+len, "/"); - len++; + buf[len++] = '/'; } - strcpy(buf+len, name); + buf[len] = '\0'; + strlcat(buf+len, name, len2); return buf; } @@ -1301,12 +1302,13 @@ if (*cur) { char *buf; char *name; - name = GLOB_ALLOC_N(char, strlen((*cur)->str) + 1); + size_t len = strlen((*cur)->str) + 1; + name = GLOB_ALLOC_N(char, len); if (!name) { status = -1; break; } - strcpy(name, (*cur)->str); + memcpy(name, (*cur)->str, len); if (escape) remove_backslashes(name, enc); new_beg = new_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/