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

ruby-changes:9234

From: usa <ko1@a...>
Date: Tue, 16 Dec 2008 11:39:02 +0900 (JST)
Subject: [ruby-changes:9234] Ruby:r20771 (trunk): * ruby.c (set_arg0): use strlcpy() instead of strncpy().

usa	2008-12-16 11:37:45 +0900 (Tue, 16 Dec 2008)

  New Revision: 20771

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20771

  Log:
    * ruby.c (set_arg0): use strlcpy() instead of strncpy().
    * load.c (rb_feature_p): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/load.c
    trunk/ruby.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20770)
+++ ChangeLog	(revision 20771)
@@ -1,3 +1,9 @@
+Tue Dec 16 11:37:07 2008  NAKAMURA Usaku  <usa@r...>
+
+	* ruby.c (set_arg0): use strlcpy() instead of strncpy().
+
+	* load.c (rb_feature_p): ditto.
+
 Tue Dec 16 09:14:28 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* parse.y (block_call): block should not be given to yield.
Index: load.c
===================================================================
--- load.c	(revision 20770)
+++ load.c	(revision 20771)
@@ -193,7 +193,7 @@
 	    buf = RSTRING_PTR(bufstr);
 	    MEMCPY(buf, feature, char, len);
 	    for (i = 0; (e = loadable_ext[i]) != 0; i++) {
-		strncpy(buf + len, e, DLEXT_MAXLEN + 1);
+		strlcpy(buf + len, e, DLEXT_MAXLEN + 1);
 		if (st_get_key(loading_tbl, (st_data_t)buf, &data)) {
 		    rb_str_resize(bufstr, 0);
 		    if (fn) *fn = (const char*)data;
Index: ruby.c
===================================================================
--- ruby.c	(revision 20770)
+++ ruby.c	(revision 20771)
@@ -1648,8 +1648,7 @@
     if (i > PST_CLEN) {
 	union pstun un;
 	char buf[PST_CLEN + 1];	/* PST_CLEN is 64 (HP-UX 11.23) */
-	strncpy(buf, s, PST_CLEN);
-	buf[PST_CLEN] = '\0';
+	strlcpy(buf, s, sizeof(buf));
 	un.pst_command = buf;
 	pstat(PSTAT_SETCMD, un, PST_CLEN, 0, 0);
     }

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

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