[#8997] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Mathieu Bouchard <matju@...>

On Tue, 3 Oct 2006, matz wrote:

77 messages 2006/10/04
[#8998] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/04

Hi,

[#9029] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Mathieu Bouchard <matju@...> 2006/10/08

On Wed, 4 Oct 2006, Yukihiro Matsumoto wrote:

[#9030] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/08

Hi,

[#9034] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Dave Burt <dave@...> 2006/10/09

Yukihiro Matsumoto wrote:

[#9041] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/09

Hi,

[#9042] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/09

Hi --

[#9043] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/09

Hi,

[#9044] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/09

Hi --

[#9045] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/09

Hi,

[#9047] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/09

Hi --

[#9050] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — James Edward Gray II <james@...> 2006/10/09

On Oct 9, 2006, at 10:19 AM, dblack@wobblini.net wrote:

[#9053] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Eero Saynatkari <ruby-ml@...> 2006/10/09

On 2006.10.10 00:31, James Edward Gray II wrote:

[#9055] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — James Edward Gray II <james@...> 2006/10/09

On Oct 9, 2006, at 11:50 AM, Eero Saynatkari wrote:

[#9056] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/09

Hi --

[#9054] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/09

Hi --

[#9066] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/09

Hi,

[#9072] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — dblack@... 2006/10/10

Hi --

[#9083] Re: [ruby-cvs:18323] ruby: * eval.c (splat_value): use "to_splat" instead of "to_ary" to — Yukihiro Matsumoto <matz@...> 2006/10/10

Hi,

[#9119] What about 'splay'? — dblack@...

Hi --

37 messages 2006/10/11
[#9122] Re: What about 'splay'? — Eero Saynatkari <ruby-ml@...> 2006/10/11

On 2006.10.12 02:32, dblack@wobblini.net wrote:

[#9127] Re: What about 'splay'? — Sean Russell <ser@...> 2006/10/11

On Wednesday 11 October 2006 13:55, Eero Saynatkari wrote:

[#9188] Symbol < String in Ruby > 1.8 — dblack@...

Hi --

107 messages 2006/10/15
[#9192] Re: Symbol < String in Ruby > 1.8 — Yukihiro Matsumoto <matz@...> 2006/10/16

Hi

[#9212] Re: Symbol < String in Ruby > 1.8 — Charles Oliver Nutter <Charles.O.Nutter@...> 2006/10/17

Yukihiro Matsumoto wrote:

[#9238] Re: Symbol < String in Ruby > 1.8 — Charles Oliver Nutter <Charles.O.Nutter@...> 2006/10/18

Charles Oliver Nutter wrote:

[#9244] Re: Symbol < String in Ruby > 1.8 — Sam Roberts <sroberts@...> 2006/10/18

On Thu, Oct 19, 2006 at 05:06:02AM +0900, Charles Oliver Nutter wrote:

[#9255] Re: Symbol < String in Ruby > 1.8 — Yukihiro Matsumoto <matz@...> 2006/10/19

Hi,

[#9256] Re: Symbol < String in Ruby > 1.8 — Sam Roberts <sroberts@...> 2006/10/19

Quoting matz@ruby-lang.org, on Thu, Oct 19, 2006 at 01:40:42PM +0900:

[#9190] Re: Symbol < String in Ruby > 1.8 — "Rick DeNatale" <rick.denatale@...> 2006/10/16

On 10/15/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#9191] Re: Symbol < String in Ruby > 1.8 — dblack@... 2006/10/16

Hi --

[#9194] Re: Symbol < String in Ruby > 1.8 — "Rick DeNatale" <rick.denatale@...> 2006/10/16

On 10/15/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#9196] Re: Symbol < String in Ruby > 1.8 — Yukihiro Matsumoto <matz@...> 2006/10/16

Hi,

[#9202] Re: Symbol < String in Ruby > 1.8 — "Rick DeNatale" <rick.denatale@...> 2006/10/16

On 10/16/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#9203] Re: Symbol < String in Ruby > 1.8 — James Edward Gray II <james@...> 2006/10/16

On Oct 16, 2006, at 3:06 PM, Rick DeNatale wrote:

[#9205] String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Sam Roberts <sroberts@...> 2006/10/16

On Tue, Oct 17, 2006 at 05:14:09AM +0900, James Edward Gray II wrote:

[#9218] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Rick DeNatale" <rick.denatale@...> 2006/10/17

On 10/16/06, Sam Roberts <sroberts@uniserve.com> wrote:

[#9220] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Nobuyoshi Nakada <nobu@...> 2006/10/17

Hi,

[#9225] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/18

Hi --

[#9226] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — James Edward Gray II <james@...> 2006/10/18

On Oct 17, 2006, at 7:29 PM, dblack@wobblini.net wrote:

[#9230] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/18

Hi --

[#9231] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Eric Hodel <drbrain@...7.net> 2006/10/18

On Oct 18, 2006, at 4:18 AM, dblack@wobblini.net wrote:

[#9232] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Nikolai Weibull" <now@...> 2006/10/18

On 10/18/06, Eric Hodel <drbrain@segment7.net> wrote:

[#9234] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — mathew <meta@...> 2006/10/18

On 10/18/06, Nikolai Weibull <now@bitwi.se> wrote:

[#9236] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Nikolai Weibull" <now@...> 2006/10/18

On 10/18/06, mathew <meta@pobox.com> wrote:

[#9237] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Mauricio Fernandez <mfp@...> 2006/10/18

On Thu, Oct 19, 2006 at 04:24:24AM +0900, Nikolai Weibull wrote:

[#9240] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Nikolai Weibull" <now@...> 2006/10/18

On 10/18/06, Mauricio Fernandez <mfp@acm.org> wrote:

[#9242] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/18

Hi --

[#9247] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Rick DeNatale" <rick.denatale@...> 2006/10/19

On 10/18/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#9250] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Jim Weirich <jim@...> 2006/10/19

Rick DeNatale wrote:

[#9261] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/19

Hi --

[#9262] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Yukihiro Matsumoto <matz@...> 2006/10/19

Hi,

[#9264] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/19

Hi --

[#9267] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Nikolai Weibull" <now@...> 2006/10/19

On 10/19/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#9277] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/19

Hi --

[#9285] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — "Nikolai Weibull" <now@...> 2006/10/20

On 10/19/06, dblack@wobblini.net <dblack@wobblini.net> wrote:

[#9288] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/20

Hi --

[#9289] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Jim Weirich <jim@...> 2006/10/20

dblack@wobblini.net wrote:

[#9294] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — Yukihiro Matsumoto <matz@...> 2006/10/20

Hi,

[#9300] Re: String not enumerable, what about IO? (was Re: Symbol < String in Ruby > 1.8) — dblack@... 2006/10/20

Hi --

Re: regular expressions tainting?

From: hadmut@... (Hadmut Danisch)
Date: 2006-10-16 08:16:56 UTC
List: ruby-core #9198
On Sun, Oct 15, 2006 at 05:33:16PM +0900, Eric Hodel wrote:
> 
> Please attach the testcase.


OK, i have stripped down the testcase further. The program does not
make much sense anymore, but still shows the bug:

The program calls 

  IPAddrRange.new("192.168.0.0-192.168.255.255")

twice, once directly and once hidden within the

  Whois.get("192.168.155.1")

call. Althoug both calls to IPAddrRange.new do the very same, it works
for the first time and then it fails for the second time, because the
regular expression engine seems to have gone into a state where it
keeps tainting any results. 


When I run the attached program the output looks like this:



% ruby WhoisBug.rb
IPAddrRangeInit 192.168.0.0-192.168.255.255 Tainted false  SAFE=1
Tainted arg false 192.168.0.0-192.168.255.255  SAFE=1
Tainted v   false |192.168.0.0|
Tainted b   false |192.168.255.255|

192.168.0.0-192.168.255.255

IPAddrRangeInit 192.168.0.0-192.168.255.255 Tainted false  SAFE=1
Tainted arg false 192.168.0.0-192.168.255.255  SAFE=1
Tainted v   false |192.168.0.0|
Tainted b   false |192.168.255.255|
Exception: invalid address  (ArgumentError)
/usr/lib/ruby/1.8/ipaddr.rb:422:in `initialize'
WhoisBug.rb:27:in `new'
WhoisBug.rb:27:in `initialize'
WhoisBug.rb:159:in `new'
WhoisBug.rb:159:in `parse'
WhoisBug.rb:137:in `each'
WhoisBug.rb:137:in `parse'
WhoisBug.rb:94:in `get_whois_net'
WhoisBug.rb:76:in `get'
WhoisBug.rb:186


So calling the same thing twice works only in the first time.

regards
Hadmut

Attachments (1)

WhoisBug.rb (3.51 KB, text/x-ruby)
# Copyright 2003-2006 Hadmut Danisch, hadmut@danisch.de

require 'thread'
require 'monitor'
require 'ipaddr'


##########################################################################

class IPAddrRange
  attr_reader :von, :bis, :mask_len


  def initialize(arg)
    @von,@bis,@mask=nil,nil,nil
    
    $stderr.puts "IPAddrRangeInit #{arg} Tainted #{arg.tainted?}  SAFE=#{$SAFE}"

    case arg

      when /^([\da-f\.:]+)\s*-\s*([\da-f\.:]+)$/i
        v,b=$1.untaint,$2.untaint
        $stderr.puts "Tainted arg #{arg.tainted?} #{arg}  SAFE=#{$SAFE}"
	$stderr.puts "Tainted v   #{v.tainted?} |#{v}|"
	$stderr.puts "Tainted b   #{b.tainted?} |#{b}|"
        @von=IPAddr.new(v)
        @bis=IPAddr.new(b)

      else
        raise "Address Range Syntax"
    end
    $stderr.puts
  end


  def to_s
    @von.to_s + "-" + @bis.to_s
  end

end






###########################################################################


class WhoisData
  attr_reader :country,:org,:range,:id,:typ

  def initialize(country,org,range,id=nil,typ=nil)
    @country,@org,@range=country,org,range
    @id=id
    @typ=1
  end


  def to_s
    "#{@country}:  #{@org}   #{@range}"
  end

end


###########################################################################

module Whois


  def Whois.get(ipaddr,dbmutex=nil)

    ipaddr  = IPAddr.new(ipaddr)
    addrkey = ipaddr.native
    result  = Whois.get_whois_net(addrkey)

    return result
  end



###########################################################################

  def Whois.get_whois_net(net,host=nil)
    #whois = `jwhois -d #{net}`
    # jwhois call replaced with static data for debugging purposes
    whois=<<ENDE
OrgName:    Internet Assigned Numbers Authority 
Country:    US
NetRange:   192.168.0.0 - 192.168.255.255 
ENDE
    whois.taint
    Whois.parse(whois)
  end




###########################################################################


  def Whois.parse(whois)

    case whois
      when String
	whois=whois.split("\n")
      when Array
	# ok
      else
	raise "Argument #{whois.class}"
    end


      wh = {}
      for zeile in whois do 
	zeile.delete!("\r\n")
	#puts "Z #{zeile}"

	case zeile 

	  when /^(\w[\w ]+\w)\s*:\s*([-_\s\w\.\,\(\)\/]+)$/
	    wh[$1]=$2 unless wh.has_key?($1)
	  
        end
      end

      #wh.keys.sort.each{|k| printf "%-20.20s %s\n",k,wh[k]}




      # Here the bug begins:
      # Problem does not occur if we pass back the same results directly
      # return "US","IANA",IPAddrRange.new("192.168.0.0 - 192.168.255.255")
      
      for i in [
  	  ["NetRange",     "OrgName",  "Country"],
  	  ["NetRange",     "NetName",  "Country"],
  	] do
  	
   	  netkey,orgkey,countrykey=*i
          if    wh.has_key?(netkey) &&
         	wh.has_key?(orgkey)  &&
  	        wh.has_key?(countrykey)	

	    addr=wh[netkey].gsub(" ","")
	 
	    case addr 
	      when /^[-\.\d]+$/
		addr=addr.untaint
	      else
	        raise "Address syntax"
	    end

	    #$stderr.puts "Angekommen #{wh[orgkey]} |#{wh[netkey]}|#{addr}|#{addr.tainted?}"
	    return  WhoisData.new(wh[countrykey],  
				  wh[orgkey],
				  IPAddrRange.new(addr)) 
	  end #if
      end #for

      return nil
    
  end









end


###########################################################################

if __FILE__ == $0
  begin

    $SAFE=1
    puts IPAddrRange.new("192.168.0.0-192.168.255.255")
    puts
    puts Whois.get("192.168.155.1")

  rescue SystemExit
    raise
  rescue Exception => exc
    $stderr.puts "Exception: #{exc}  (#{exc.class.to_s})"
    $stderr.puts exc.backtrace
    exit 99
  end

end

In This Thread