Str_new() may create broken string

e$B%o%J%Y$H?=$7$^$9!#e(B

str_new e$B4X?t$G:n$i$l$?J8;zNs$N%P%$%HNs$,=i4|2=$5$l$F$$$J$$$?$a!“e(B
e$B3F%(%s%3!<%G%#%s%0$Ne(B mbc_enc_len
e$B$J$I$,@5>o$KF0$+$J$$>l9g$,$”$j$^$9!#e(B
e$B<j85$N4D6-$G$O!"FC$Ke(B rb_file_expand_path
e$B$G$h$/5/$3$k$h$&$G$7$?!#e(B
e$B0J2<%Q%C%A$G$9!#e(B

Index: string.c

— string.c (revision 15984)
+++ string.c (working copy)
@@ -371,6 +371,9 @@
if (ptr) {
memcpy(RSTRING_PTR(str), ptr, len);
}

  • else {
  •   MEMZERO(RSTRING_PTR(str), char, len);
    
  • }
    STR_SET_LEN(str, len);
    RSTRING_PTR(str)[len] = ‘\0’;
    return str;

[email protected]$G$9!#e(B

At Wed, 16 Apr 2008 20:49:48 +0900,
wanabe wrote in [ruby-dev:34430]:

str_new e$B4X?t$G:n$i$l$?J8;zNs$N%P%$%HNs$,=i4|2=$5$l$F$$$J$$$?$a!“e(B
e$B3F%(%s%3!<%G%#%s%0$Ne(B mbc_enc_len e$B$J$I$,@5>o$KF0$+$J$$>l9g$,$”$j$^$9!#e(B
e$B<j85$N4D6-$G$O!"FC$Ke(B rb_file_expand_path e$B$G$h$/5/$3$k$h$&$G$7$?!#e(B

[email protected],e(B1bytee$B$r%/%j%"[email protected]$1$G$OIT==J,$G$7$g$&$+!#e(B

Nobuyoshi N.:

[email protected],e(B1bytee$B$r%/%j%"[email protected]$1$G$OIT==J,$G$7$g$&$+!#e(B

UTF16e$B$H$+$G$^$:$=$&$J5$$,$7$^$9$,!"$I$&$J$s$G$7$?$C$1!)e(B

[email protected]$G$9!#e(B

At Thu, 17 Apr 2008 13:34:09 +0900,
[email protected] wrote in [ruby-dev:34436]:

[email protected],e(B1bytee$B$r%/%j%"[email protected]$1$G$OIT==J,$G$7$g$&$+!#e(B

UTF16e$B$H$+$G$^$:$=$&$J5$$,$7$^$9$,!"$I$&$J$s$G$7$?$C$1!)e(B

e$B$s$8$ce(B
MEMZERO(RSTRING_PTR(str), char, RSTRING_EMBED_LEN_MAX+1);
e$B$/$i$$$G!#e(B

In article
[email protected],
wanabe [email protected] writes:

str_new e$B4X?t$G:n$i$l$?J8;zNs$N%P%$%HNs$,=i4|2=$5$l$F$$$J$$$?$a!“e(B
e$B3F%(%s%3!<%G%#%s%0$Ne(B mbc_enc_len e$B$J$I$,@5>o$KF0$+$J$$>l9g$,$”$j$^$9!#e(B
e$B<j85$N4D6-$G$O!"FC$Ke(B rb_file_expand_path e$B$G$h$/5/$3$k$h$&$G$7$?!#e(B
e$B0J2<%Q%C%A$G$9!#e(B

e$BJ8;z$,$J$$$H$3$m$Ke(B mbc_enc_len e$B$rE,MQ$9$k$H$3$m$,$=$b$=$b$*e(B
e$B$+$7$$$H;W$&$s$G$9$,!"$I$&$$$&Nc$GH/@8$9$k$s$G$7$g$&$+!#e(B

e$B%o%J%Y$G$9!#e(B

08/04/17 e$B$Ke(B Tanaka A.[email protected] e$B$5$s$O=q$-$^$7$?e(B:

e$BJ8;z$,$J$$$H$3$m$Ke(B mbc_enc_len e$B$rE,MQ$9$k$H$3$m$,$=$b$=$b$*e(B
e$B$+$7$$$H;W$&$s$G$9$,!"$I$&$$$&Nc$GH/@8$9$k$s$G$7$g$&$+!#e(B

e$B3N$+$K$=$&$G$9$M!#LdBj$r40A4$K8+8m$C$F$$$^$7$?!#e(B
str_new()e$B$NLdBj$G$O$J$/!"e(Bfile_expand_path()e$BCf$Ge(B
e$BJ8;zNsD9$,7h$^$kA0$Ke(Brb_enc_check()e$B$,8F$P$l$k$3$H$,[email protected]$C$?$h$&$G$9!#e(B

e$B$5$i$K!"$3$NLdBj$O$9$G$K%j%S%8%g%se(B
[email protected]$5$l$F$$$^$7$?!#e(B
e$B%A%’%C%/$7B;$M$F$$$^$7$?!#$9$_$^$;$s!#e(B
e$B!J<XB-$K$J$j$^$9$,!"0JA0$Oe(B sample/test.rb e$BCf$Ne(B
File.expand_path e$B$NJV$jCM$He(B
e$B!!@55,I=8=$H$N%^%C%A%s%0ItJ,$Ge(B "broken Windows-31J
string"e$B$H$J$C$F$$$^$7$?!#!Ke(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs