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

ruby-changes:3585

From: ko1@a...
Date: Wed, 16 Jan 2008 15:26:54 +0900 (JST)
Subject: [ruby-changes:3585] nobu - Ruby:r15074 (trunk): * load.c (rb_feature_p): get rid of unlimited alloca.

nobu	2008-01-16 15:26:33 +0900 (Wed, 16 Jan 2008)

  New Revision: 15074

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/load.c
    trunk/object.c

  Log:
    * load.c (rb_feature_p): get rid of unlimited alloca.
    
    * object.c (rb_cstr_to_dbl): ditto.
    
    * io.c (mode_enc): fixed uninitialized variable.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/load.c?r1=15074&r2=15073&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15074&r2=15073&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=15074&r2=15073&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/object.c?r1=15074&r2=15073&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15073)
+++ ChangeLog	(revision 15074)
@@ -1,9 +1,21 @@
-Wed Jan 16 14:55:15 2008  Nobuyoshi Nakada  <nobu@r...>
+Wed Jan 16 15:26:31 2008  Nobuyoshi Nakada  <nobu@r...>
 
+	* load.c (rb_feature_p): get rid of unlimited alloca.
+
+	* object.c (rb_cstr_to_dbl): ditto.
+
+	* io.c (mode_enc): fixed uninitialized variable.
+
 	* file.c (sys_fail2): get rid of unlimited alloca.
 
 	* io.c (mode_enc, pipe_open, rb_io_s_popen): ditto.
 
+	* load.c (rb_feature_p): ditto.
+
+	* object.c (rb_cstr_to_dbl): ditto.
+
+	* io.c (mode_enc): fixed uninitialized variable.
+
 Wed Jan 16 12:51:30 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/intern.h (rb_str_tmp_new, rb_str_shared_replace):
Index: object.c
===================================================================
--- object.c	(revision 15073)
+++ object.c	(revision 15074)
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <math.h>
+#include <float.h>
 
 VALUE rb_cBasicObject;
 VALUE rb_mKernel;
@@ -2048,15 +2049,16 @@
 	return d;
     }
     if (*end) {
-	char *buf = ALLOCA_N(char, strlen(p)+1);
+	char buf[DBL_DIG * 4 + 10];
 	char *n = buf;
+	char *e = buf + sizeof(buf) - 1;
 
-	while (p < end) *n++ = *p++;
-	while (*p) {
+	while (p < end && n < e) *n++ = *p++;
+	while (n < e && *p) {
 	    if (*p == '_') {
 		/* remove underscores between digits */
-		    if (n == buf || !ISDIGIT(n[-1])) goto bad;
-		    while (*++p == '_');
+		if (n == buf || !ISDIGIT(n[-1])) goto bad;
+		while (*++p == '_');
 		if (!ISDIGIT(*p)) {
 		    if (badcheck) goto bad;
 		    break;
Index: io.c
===================================================================
--- io.c	(revision 15073)
+++ io.c	(revision 15074)
@@ -3192,14 +3192,15 @@
 	    enc2name = ALLOCA_N(char, n+1);
 	    memcpy(enc2name, estr, n);
 	    enc2name[n] = '\0';
+	    estr = enc2name;
 	    idx2 = rb_enc_find_index(enc2name);
 	}
 	if (idx2 < 0) {
-	    rb_warn("Unsupported encoding %s ignored", enc2name);
+	    rb_warn("Unsupported encoding %.*s ignored", n, estr);
 	}
 	else if (idx2 == idx) {
-	    rb_warn("Ignoring internal encoding %s: it is identical to external encoding %s",
-		    enc2name, p1);
+	    rb_warn("Ignoring internal encoding %.*s: it is identical to external encoding %s",
+		    n, estr, p1);
 	}
 	else {
 	    fptr->enc2 = rb_enc_from_index(idx2);
Index: load.c
===================================================================
--- load.c	(revision 15073)
+++ load.c	(revision 15074)
@@ -166,18 +166,22 @@
 	    return !IS_RBEXT(ext) ? 's' : 'r';
 	}
 	else {
+	    VALUE bufstr;
 	    char *buf;
 
 	    if (ext && *ext) return 0;
-	    buf = ALLOCA_N(char, len + DLEXT_MAXLEN + 1);
+	    bufstr = rb_str_tmp_new(len + DLEXT_MAXLEN);
+	    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);
 		if (st_get_key(loading_tbl, (st_data_t)buf, &data)) {
+		    rb_str_resize(bufstr, 0);
 		    if (fn) *fn = (const char*)data;
 		    return i ? 's' : 'r';
 		}
 	    }
+	    rb_str_resize(bufstr, 0);
 	}
     }
     return 0;

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

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