[#11073] segfault printing instruction sequence for iterator — <noreply@...>

Bugs item #10527, was opened at 2007-05-02 14:42

14 messages 2007/05/02
[#11142] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Nobuyoshi Nakada <nobu@...> 2007/05/10

Hi,

[#11188] Re: [ ruby-Bugs-10527 ] segfault printing instruction sequence for iterator — Paul Brannan <pbrannan@...> 2007/05/16

On Thu, May 10, 2007 at 04:51:18PM +0900, Nobuyoshi Nakada wrote:

[#11234] Planning to release 1.8.6 errata — Urabe Shyouhei <shyouhei@...>

Hi all.

17 messages 2007/05/25

Re: Net::Telnet and EOF

From: Brian Candler <B.Candler@...>
Date: 2007-05-31 13:45:40 UTC
List: ruby-core #11380
Here are some lightly-tested patches.

(1) A patch to Net::Telnet which adds a new option "FailEOF". If you specify

    sock = Net::Telnet.new(...., "FailEOF" => true)
or
    sock.waitfor("Match" => /foo/, "FailEOF" => true)

then if the remote side closes the connection before the expected response is
seen, an EOFError will be raised. If this option is not set then the old
behaviour is maintained.

(2) A patch to IO#expect which raises EOFError instead of NoMethodError if
the remote side closes the connection before the expected response is seen.

Regards,

Brian.

Attachments (2)

net-telnet.diff (1.42 KB, text/x-diff)
--- /usr/lib/ruby/1.8/net/telnet.rb	2005-09-14 16:21:31.000000000 +0100
+++ telnet.rb	2007-05-31 14:43:21.000000000 +0100
@@ -520,10 +520,15 @@
     #            value specified when this instance was created will be
     #            used, or, failing that, the default value of 0 seconds,
     #            which means not to wait for more input.
+    # FailEOF:: if true, when the remote end closes the connection then an
+    #           EOFError will be raised. Otherwise, defaults to the old
+    #           behaviour that the function will return whatever data
+    #           has been received already, or nil if nothing was received.
     #           
     def waitfor(options) # :yield: recvdata
       time_out = @options["Timeout"]
       waittime = @options["Waittime"]
+      fail_eof = @options["FailEOF"]
 
       if options.kind_of?(Hash)
         prompt   = if options.has_key?("Match")
@@ -535,6 +540,7 @@
                    end
         time_out = options["Timeout"]  if options.has_key?("Timeout")
         waittime = options["Waittime"] if options.has_key?("Waittime")
+        fail_eof = options["FailEOF"]  if options.has_key?("FailEOF")
       else
         prompt = options
       end
@@ -579,6 +585,7 @@
           line += buf
           yield buf if block_given?
         rescue EOFError # End of file reached
+          raise if fail_eof
           if line == ''
             line = nil
             yield nil if block_given?
expect.diff (320 Bytes, text/x-diff)
--- /usr/lib/ruby/1.8/expect.rb	2006-11-22 14:06:58.000000000 +0000
+++ lib/rds/expect.rb	2007-05-31 14:40:22.000000000 +0100
@@ -14,7 +14,7 @@
         result = nil
         break
       end
-      c = getc.chr
+      c = (getc || (raise EOFError)).chr
       buf << c
       if $expect_verbose
         STDOUT.print c

In This Thread