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

ruby-changes:3797

From: ko1@a...
Date: Mon, 28 Jan 2008 12:32:42 +0900 (JST)
Subject: [ruby-changes:3797] matz - Ruby:r15286 (trunk): * io.c (rb_open_file): should check NUL in path.

matz	2008-01-28 12:32:27 +0900 (Mon, 28 Jan 2008)

  New Revision: 15286

  Modified files:
    trunk/ChangeLog
    trunk/io.c

  Log:
    * io.c (rb_open_file): should check NUL in path.
      <http://www.rubyist.net/~matz/20080125.html#c01>.
    
    * io.c (rb_io_s_popen): ditto.
    
    * io.c (rb_io_reopen): ditto.
    
    * io.c (next_argv): ditto.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15286&r2=15285&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=15286&r2=15285&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15285)
+++ ChangeLog	(revision 15286)
@@ -15,6 +15,17 @@
 
 	* parse.y (parser_set_encode): check if encoding is ASCII compatible.
 
+Mon Jan 28 01:21:15 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* io.c (rb_open_file): should check NUL in path.
+	  <http://www.rubyist.net/~matz/20080125.html#c01>.
+
+	* io.c (rb_io_s_popen): ditto.
+
+	* io.c (rb_io_reopen): ditto.
+
+	* io.c (next_argv): ditto.
+
 Sun Jan 27 23:33:35 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* sprintf.c (rb_str_format): fix for left justify flag.
Index: io.c
===================================================================
--- io.c	(revision 15285)
+++ io.c	(revision 15286)
@@ -3653,7 +3653,7 @@
 	argbuf = rb_str_tmp_new((argc+1) * sizeof(char *));
 	args = (void *)RSTRING_PTR(argbuf);
 	for (i = 0; i < argc; ++i) {
-	    args[i] = RSTRING_PTR(argv[i]);
+	    args[i] = StringValueCStr(argv[i]);
 	}
 	args[i] = NULL;
 	exename = cmd;
@@ -3717,7 +3717,7 @@
     const char *cmd;
 
     if (!RB_GC_GUARD(prog)) prog = argv[0];
-    cmd = RSTRING_PTR(prog);
+    cmd = StringValueCStr(prog);
     return pipe_open(cmd, argc, argv, mode);
 }
 
@@ -3802,7 +3802,7 @@
 	mode = rb_io_modenum_mode(FIX2INT(pmode));
     }
     else {
-	mode = StringValuePtr(pmode);
+	mode = StringValueCStr(pmode);
     }
     tmp = rb_check_array_type(pname);
     if (!NIL_P(tmp)) {
@@ -3848,7 +3848,7 @@
 	}
 	else {
 	    SafeStringValue(vmode);
-	    flags = rb_io_mode_modenum(RSTRING_PTR(vmode));
+	    flags = rb_io_mode_modenum(StringValueCStr(vmode));
 	}
 	fmode = NIL_P(perm) ? 0666 :  NUM2INT(perm);
 
@@ -3856,7 +3856,7 @@
     }
     else {
 
-	mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
+	mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);
 	rb_file_open_internal(io, RSTRING_PTR(fname), mode);
     }
     return io;
@@ -3912,7 +3912,7 @@
     else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
     else {
 	SafeStringValue(vmode);
-	flags = rb_io_mode_modenum(RSTRING_PTR(vmode));
+	flags = rb_io_mode_modenum(StringValueCStr(vmode));
     }
     if (NIL_P(perm)) fmode = 0666;
     else             fmode = NUM2INT(perm);
@@ -4207,7 +4207,7 @@
     }
 
     if (!NIL_P(nmode)) {
-	int flags = rb_io_mode_flags(StringValuePtr(nmode));
+	int flags = rb_io_mode_flags(StringValueCStr(nmode));
 	if (IS_PREP_STDIO(fptr) &&
             ((fptr->mode & FMODE_READWRITE) & (flags & FMODE_READWRITE)) !=
             (fptr->mode & FMODE_READWRITE)) {
@@ -4225,7 +4225,7 @@
 	fptr->path = 0;
     }
 
-    fptr->path = strdup(RSTRING_PTR(fname));
+    fptr->path = strdup(StringValueCStr(fname));
     mode = rb_io_flags_mode(fptr->mode);
     if (fptr->fd < 0) {
         fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(mode), 0666);
@@ -4238,13 +4238,13 @@
     }
 
     if (fptr->stdio_file) {
-        if (freopen(RSTRING_PTR(fname), mode, fptr->stdio_file) == 0) {
+        if (freopen(fptr->path, mode, fptr->stdio_file) == 0) {
             rb_sys_fail(fptr->path);
         }
         fptr->fd = fileno(fptr->stdio_file);
 #ifdef USE_SETVBUF
         if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0)
-            rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fname));
+            rb_warn("setvbuf() can't be honoured for %s", fptr->path);
 #endif
     }
     else {
@@ -4741,7 +4741,7 @@
 	}
 	else {
 	    SafeStringValue(mode);
-	    flags = rb_io_mode_modenum(RSTRING_PTR(mode));
+	    flags = rb_io_mode_modenum(StringValueCStr(mode));
 	}
     }
     orig = rb_io_check_io(fnum);
@@ -4765,7 +4765,7 @@
 	GetOpenFile(orig, ofp);
 	if (ofp->refcnt == LONG_MAX) {
 	    VALUE s = rb_inspect(orig);
-	    rb_raise(rb_eIOError, "too many shared IO for %s", StringValuePtr(s));
+	    rb_raise(rb_eIOError, "too many shared IO for %s", StringValueCStr(s));
 	}
 	if (argc == 2) {
 	    fmode = rb_io_modenum_flags(flags);
@@ -4927,7 +4927,7 @@
       retry:
 	if (RARRAY_LEN(rb_argv) > 0) {
 	    filename = rb_ary_shift(rb_argv);
-	    fn = StringValuePtr(filename);
+	    fn = StringValueCStr(filename);
 	    if (strlen(fn) == 1 && fn[0] == '-') {
 		current_file = rb_stdin;
 		if (ruby_inplace_mode) {
@@ -5601,7 +5601,7 @@
 	if (!NIL_P(v)) {
 	    StringValue(v);
 	    rb_str_modify(v);
-	    arg[i] = (unsigned long)RSTRING_PTR(v);
+	    arg[i] = (unsigned long)StringValueCStr(v);
 	}
 	else {
 	    arg[i] = (unsigned long)NUM2LONG(*argv);
@@ -6440,7 +6440,7 @@
     StringValue(val);
     if (ruby_inplace_mode) free(ruby_inplace_mode);
     ruby_inplace_mode = 0;
-    ruby_inplace_mode = strdup(RSTRING_PTR(val));
+    ruby_inplace_mode = strdup(StringValueCStr(val));
 }
 
 /*

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

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