[Bug:ruby 1.9] cannot open file with big mode value

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

io.ce$B$NCf$G!“e(Bopen()e$B$K:G=E$KEO$5$l$ke(Bmodee$B$re(BNUM2INTe$B$G@8@.$7$F$$e(B
e$B$k$H$3$m$,?t2U=j$”$k$N$G$9$,!"e(Bmodee$B$,e(Bunsigned
inte$B$J4D6-$G:G>ee(B
e$B0L%S%C%H$^$G;H$C$F$$$k>l9g$K%(%i!<$K$J$C$F$7$^$$$^$9!#e(B

Index: io.c

— io.c (revision 16865)
+++ io.c (working copy)
@@ -4017,7 +4017,8 @@ rb_open_file(int argc, VALUE *argv, VALU
{
VALUE fname, vmode, perm;
const char *mode;

  • int flags, fmode;
  • int flags;

  • unsigned int fmode;

    rb_scan_args(argc, argv, “12”, &fname, &vmode, &perm);
    FilePathValue(fname);
    @@ -4030,7 +4031,7 @@ rb_open_file(int argc, VALUE *argv, VALU
    SafeStringValue(vmode);
    flags = rb_io_mode_modenum(StringValueCStr(vmode));
    }

  • fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
  • fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm);

    rb_file_sysopen_internal(io, RSTRING_PTR(fname), flags, fmode);
    }
    @@ -4082,7 +4083,8 @@ static VALUE
    rb_io_s_sysopen(int argc, VALUE *argv)
    {
    VALUE fname, vmode, perm;

  • int flags, fmode, fd;
  • int flags, fd;

  • unsigned int fmode;
    char *path;

    rb_scan_args(argc, argv, “12”, &fname, &vmode, &perm);
    @@ -4095,7 +4097,7 @@ rb_io_s_sysopen(int argc, VALUE *argv)
    flags = rb_io_mode_modenum(StringValueCStr(vmode));
    }
    if (NIL_P(perm)) fmode = 0666;

  • else fmode = NUM2INT(perm);
  • else fmode = NUM2UINT(perm);

    RB_GC_GUARD(fname) = rb_str_new4(fname);
    path = RSTRING_PTR(fname);

e$B87L)$J$3$H$r8@$&$H!"e(Bmodee$B$Oe(Bmode_te$B$G07$&$Y$-5$$b$7$^$9$,e(B…

e$B$=$l$G$O!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34979] [Bug:ruby 1.9] cannot open file with
big mode value”
on Sat, 7 Jun 2008 00:53:17 +0900, “U.Nakamura”
[email protected] writes:

|io.ce$B$NCf$G!“e(Bopen()e$B$K:G=E$KEO$5$l$ke(Bmodee$B$re(BNUM2INTe$B$G@8@.$7$F$$e(B
|e$B$k$H$3$m$,?t2U=j$”$k$N$G$9$,!"e(Bmodee$B$,e(Bunsigned inte$B$J4D6-$G:G>ee(B
|e$B0L%S%C%H$^$G;H$C$F$$$k>l9g$K%(%i!<$K$J$C$F$7$^$$$^$9!#e(B

e$B%3%_%C%H$7$F$/$@$5$$!#e(B

|# e$B87L)$J$3$H$r8@$&$H!"e(Bmodee$B$Oe(Bmode_te$B$G07$&$Y$-5$$b$7$^$9$,e(B…

e$B:#!“e(Bmode_te$B$C$F$I$3$K$G$b$”$k$b$N$J$s$G$7$?$C$1!#e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:34980] Re: [Bug:ruby 1.9] cannot open file with
big mode value”
on Jun.07,2008 00:59:30, [email protected] wrote:

|# e$B87L)$J$3$H$r8@$&$H!"e(Bmodee$B$Oe(Bmode_te$B$G07$&$Y$-5$$b$7$^$9$,e(B…

e$B:#!“e(Bmode_te$B$C$F$I$3$K$G$b$”$k$b$N$J$s$G$7$?$C$1!#e(B

e$B$I$3$K$G$b$O$J$$$+$b$7$l$J$$$N$G!“e(Bconfiguree$B$G%A%'%C%/$7$F!”$Je(B
e$B$+$C$?$ie(Bunsigned inte$B$K$G$b$9$k$N$+$J$“!”$H;W$$$^$9!#e(B
e$B$H$j$"$($:e(Bconfigure.ine$B$r$$$8$k5$NO$,$J$$$7e(Bmode_te$B$,e(Bunsigned
int
e$B$h$jBg$-$$4D6-$bCN$i$J$$$N$GJ]N1$7$^$7$?!#e(B

e$B$=$l$G$O!#e(B

e$B@.@%$G$9!#e(B

U.Nakamura wrote:

e$B$H$j$"$($:e(Bconfigure.ine$B$r$$$8$k5$NO$,$J$$$7e(Bmode_te$B$,e(Bunsigned int
e$B$h$jBg$-$$4D6-$bCN$i$J$$$N$GJ]N1$7$^$7$?!#e(B

e$B0JA0:n$C$?e(B RUBY_DEFINT
e$B$r;H$($Pe(B1e$B9TDI2C$9$k$@$1$@$C$?$j$7$^$;$s$+$M!#e(B