2005-01-20 (Thu)
_ [Ruby] 汚染状態の伝搬
分かってると思うけど、
汚染されている文字列や 汚染されている文字列を指しているオブジェクトから to_sとかinspectとかで生成される文字列は汚染される.
[雄也の?日坊主日記(2005-01-19)より引用]
というのは常に成り立つわけじゃないよね。
class Foo
def initialize(s)
@s = s
end
end
f = Foo.new("abc".taint)
s = f.to_s
p s #=> "#<Foo:0xb7d5a778>"
p s.tainted? #=> false
s2 = f.inspect
p s2 #=> "#<Foo:0xb7d5a778 @s=\"abc\">"
p s2.tainted? #=> true
重要なのは、fが「汚染されている文字列を指している」かどうかではなくて、 to_sやinspectが汚染されている文字列を使うかどうか。 上の例だと、to_sには@sの値はまったく使用されないので、汚染が伝搬しない (する必要がない)。
[ツッコミを入れる]
[TrackBack URL: http://shugo.net/jit/tb.rb/20050120]
本日のリンク元
- http://www.j96.org/~yuya/d/?category=Ruby ×9
- http://blog.chew.jp/result/abc/abc false ×7
- http://wordtantei.com/result/ABC/abc 宅配 ×5
- http://wordtantei.com/result/ABC/abc ランド ×5
- http://wordtantei.com/result/abc/abc商会 ×5
- http://wordtantei.com/result/abc/グアム abc ×5
- http://search.live.com/results.aspx?q=result ×5
- http://wordtantei.com/result/ABC/abc 空港 ×4
- http://wordtantei.com/result/ABC/ブリトニー abc ×4
- http://wordtantei.com/result/ABC/abcホール ×4
- http://bloger.x0.com/result/abc/abc 文字列 ×4
- http://wordtantei.com/result/ABC/abcランド ×4
- http://www.j96.org/~yuya/d/ ×4
- http://wordtantei.com/result/ABC/富士ソフト abc ×4
- http://wordtantei.com/result/abc/abc face ×4
- http://wordtantei.com/result/ABC/abc分析 ×3
- http://search.live.com/results.aspx?q=result&mrt=e... ×3
- http://www.banana-fish.com/~piro/200411.html ×3
- http://wordtantei.com/result/abc/abc 商会 ×2
- http://wordtantei.com/result/ABC/abcサービス ×2
- http://blog.chew.jp/result/abc/abc 文字列 ×2
- http://wordtantei.com/result/abc/abc パン ×2
- http://www.j96.org/~yuya/d/20050119.html ×2
- http://wordtantei.com/result/abc/abc jal ×2
- http://wordtantei.com/result/abc/abc 英会話 ×2
- http://wordtantei.com/result/ABC/abcストア ×2
- http://wordtantei.com/result/ABC/abcホーム ×2
- http://wordtantei.com/result/abc/abc サービス ×2
- tDiary.Net[kazuhiko](2004-07-30) ×2
- http://wordtantei.com/result/ABC/abc セレブ ×2
- http://search.live.com/results.aspx?q=result&form=... ×2
- http://mixi.jp/new_friend_diary.pl ×2
- http://wordtantei.com/result/abc/abc パチンコ ×1
- http://wordtantei.com/result/abc/abc 新人 ×1
- http://looseend.ddo.jp/blog/9 ×1
- http://www.sfa-cms.com/word/坊主/坊主 丸刈り フェチ ×1
- http://216.239.37.104/translate_c?hl=en&sl=ja&u=ht... ×1
- http://sbs.mobile.yahoo.co.jp/union/search?p=汚染 ×1
- http://blog.chew.jp/result/abc/abc+文字列 ×1
- http://wordtantei.com/result/ABC/jojo abc ×1
- http://search.live.com/results.aspx?q=坊主・丸刈り&first... ×1
- http://www.j96.org/~yuya/d/?category=ALL ×1
- http://www.sfa-cms.com/word/ゴシップ/abc ゴシップ ×1
- http://wordtantei.com/result/ABC/abc お笑い ×1
- http://wordtantei.com/result/ABC/abc情報館 ×1
- http://wordtantei.com/result/abc/abc hobby ×1
- http://209.85.175.104/search?q=cache:Bpk9r7tofcAJ:... ×1
- http://wordtantei.com/result/ABC/abcホールディングス ×1
- http://www.irekae.com/word/坊主/坊主 丸刈り フェチ ×1
- http://blog.chew.jp/result/YUYA/YUYA ×1
- http://search.live.com/spresults.aspx?q=汚染される前 ×1
- http://seo-cms.sub.jp/data/ABC/index.html ×1
- http://wordtantei.com/result/ABC/abc商会 ×1
- http://wordtantei.com/result/ABC/abc クッキングスクール ×1
- http://wordtantei.com/result/ABC/abc ホビー ×1
- http://youtubekensaku.com/パチンコ/1 ×1
- http://www.dm4lab.to/~usa/ruby/d/ ×1
- http://wordtantei.com/result/ABC/vans abc ×1
- http://caojon.seesaa.net/archives/200404.html ×1
- http://search.mobile.yahoo.co.jp/p/search/pcsite/l... ×1
- http://wordtantei.com/result/abc/abc 成田 ×1
- http://wordtantei.com/result/ABC/abc ゴルフ ×1
- http://r.hatena.ne.jp/rhosoi/Nerds/ ×1
- http://209.85.175.104/search?q=cache:Bpk9r7tofcAJ:... ×1
- http://209.85.175.104/search?q=cache:Bpk9r7tofcAJ:... ×1
