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

ruby-changes:11514

From: nobu <ko1@a...>
Date: Mon, 6 Apr 2009 16:39:03 +0900 (JST)
Subject: [ruby-changes:11514] Ruby:r23140 (trunk): * file.c (sys_fail2, rb_file_s_readlink, BUFCHECK, rmext),

nobu	2009-04-06 16:38:52 +0900 (Mon, 06 Apr 2009)

  New Revision: 23140

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

  Log:
    * file.c (sys_fail2, rb_file_s_readlink, BUFCHECK, rmext),
      (rb_file_s_basename): get rid of overflow.

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/numeric.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23139)
+++ ChangeLog	(revision 23140)
@@ -1,3 +1,8 @@
+Mon Apr  6 16:38:50 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (sys_fail2, rb_file_s_readlink, BUFCHECK, rmext),
+	  (rb_file_s_basename): get rid of overflow.
+
 Mon Apr  6 15:11:56 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* numeric.c (int_chr): checsk overflow.
Index: numeric.c
===================================================================
--- numeric.c	(revision 23139)
+++ numeric.c	(revision 23140)
@@ -1974,7 +1974,7 @@
 #endif
     if (i < 0 || (n = rb_enc_codelen((int)i, enc)) <= 0) goto out_of_range;
     str = rb_enc_str_new(0, n, enc);
-    rb_enc_mbcput(i, RSTRING_PTR(str), enc);
+    rb_enc_mbcput((int)i, RSTRING_PTR(str), enc);
     return str;
 }
 
Index: file.c
===================================================================
--- file.c	(revision 23139)
+++ file.c	(revision 23140)
@@ -2107,9 +2107,9 @@
 
     if (tsp) {
         tvbuf[0].tv_sec = tsp[0].tv_sec;
-        tvbuf[0].tv_usec = tsp[0].tv_nsec / 1000;
+        tvbuf[0].tv_usec = (int)(tsp[0].tv_nsec / 1000);
         tvbuf[1].tv_sec = tsp[1].tv_sec;
-        tvbuf[1].tv_usec = tsp[1].tv_nsec / 1000;
+        tvbuf[1].tv_usec = (int)(tsp[1].tv_nsec / 1000);
         tvp = tvbuf;
     }
     if (utimes(path, tvp) < 0)
@@ -2182,7 +2182,7 @@
 #endif
     const char *e1, *e2;
     int len = 5;
-    int l1 = RSTRING_LEN(s1), l2 = RSTRING_LEN(s2);
+    long l1 = RSTRING_LEN(s1), l2 = RSTRING_LEN(s2);
 
     e1 = e2 = "";
     if (l1 > max_pathlen) {
@@ -2195,11 +2195,11 @@
 	e2 = "...";
 	len += 3;
     }
-    len += l1 + l2;
+    len += (int)l1 + (int)l2;
     buf = ALLOCA_N(char, len);
     snprintf(buf, len, "(%.*s%s, %.*s%s)",
-	     l1, RSTRING_PTR(s1), e1,
-	     l2, RSTRING_PTR(s2), e2);
+	     (int)l1, RSTRING_PTR(s1), e1,
+	     (int)l2, RSTRING_PTR(s2), e2);
     rb_sys_fail(buf);
 }
 
@@ -2280,7 +2280,7 @@
 #ifdef HAVE_READLINK
     char *buf;
     int size = 100;
-    int rv;
+    ssize_t rv;
     VALUE v;
 
     rb_secure(2);
@@ -2594,7 +2594,7 @@
 #endif
 
 #define BUFCHECK(cond) do {\
-    long bdiff = p - buf;\
+    size_t bdiff = p - buf;\
     if (cond) {\
 	do {buflen *= 2;} while (cond);\
 	rb_str_resize(result, buflen);\
@@ -2993,10 +2993,10 @@
     return rb_file_absolute_path(fname, dname);
 }
 
-static int
-rmext(const char *p, int l1, const char *e)
+static size_t
+rmext(const char *p, long l1, const char *e)
 {
-    int l0, l2;
+    long l0, l2;
 
     if (!e) return 0;
 
@@ -3047,7 +3047,7 @@
 #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
     const char *root;
 #endif
-    int f, n;
+    long f, n;
 
     if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
 	StringValue(fext);
@@ -4581,7 +4581,7 @@
 		if (!is_absolute_path(f)) fname = rb_file_expand_path(fname, Qnil);
 		OBJ_FREEZE(fname);
 		*filep = fname;
-		return i+1;
+		return (int)(i+1);
 	    }
 	    rb_str_set_len(fname, fnlen);
 	}
@@ -4607,7 +4607,7 @@
 		RBASIC(tmp)->klass = rb_obj_class(*filep);
 		OBJ_FREEZE(tmp);
 		*filep = tmp;
-		return j+1;
+		return (int)(j+1);
 	    }
 	    FL_UNSET(tmp, FL_TAINT | FL_UNTRUSTED);
 	}

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

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