[前][次][番号順一覧][スレッド一覧]

ruby-changes:38935

From: normal <ko1@a...>
Date: Thu, 25 Jun 2015 02:44:29 +0900 (JST)
Subject: [ruby-changes:38935] normal:r51016 (trunk): ext/openssl/ossl_ssl.c: raise if kwargs given in blocking mode

normal	2015-06-25 02:44:01 +0900 (Thu, 25 Jun 2015)

  New Revision: 51016

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51016

  Log:
    ext/openssl/ossl_ssl.c: raise if kwargs given in blocking mode
    
    OpenSSL::SSL::SSLSocket#sysread does not accept kwargs in blocking
    mode, inform users if they make an error.
    
    * ext/openssl/ossl_ssl.c (ossl_ssl_read_internal):
      do not process kwargs in blocking mode
    * test/openssl/test_ssl.rb: test sysread

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl_ssl.c
    trunk/test/openssl/test_ssl.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51015)
+++ ChangeLog	(revision 51016)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 25 02:40:33 2015  Eric Wong  <e@8...>
+
+	* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal):
+	  do not process kwargs in blocking mode
+	* test/openssl/test_ssl.rb: test sysread
+
 Wed Jun 24 16:54:11 2015  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_mark_children): add additional debug code for #11244.
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 51015)
+++ ext/openssl/ossl_ssl.c	(revision 51016)
@@ -1430,13 +1430,17 @@ ossl_ssl_read_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1430
 {
     SSL *ssl;
     int ilen, nread = 0;
-    int no_exception;
+    int no_exception = 0;
     VALUE len, str;
     rb_io_t *fptr;
     VALUE opts = Qnil;
 
-    rb_scan_args(argc, argv, "11:", &len, &str, &opts);
-    no_exception = get_no_exception(opts);
+    if (nonblock) {
+	rb_scan_args(argc, argv, "11:", &len, &str, &opts);
+	no_exception = get_no_exception(opts);
+    } else {
+	rb_scan_args(argc, argv, "11", &len, &str);
+    }
 
     ilen = NUM2INT(len);
     if(NIL_P(str)) str = rb_str_new(0, ilen);
Index: test/openssl/test_ssl.rb
===================================================================
--- test/openssl/test_ssl.rb	(revision 51015)
+++ test/openssl/test_ssl.rb	(revision 51016)
@@ -60,6 +60,20 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L60
     }
   end
 
+  def test_ssl_sysread_blocking_error
+    start_server(OpenSSL::SSL::VERIFY_NONE, true) { |server, port|
+      server_connect(port) { |ssl|
+        ssl.write("abc\n")
+        assert_raise(TypeError) { ssl.sysread(4, exception: false) }
+        buf = ''
+        assert_raise(ArgumentError) { ssl.sysread(4, buf, exception: false) }
+        assert_equal '', buf
+        assert_equal buf.object_id, ssl.sysread(4, buf).object_id
+        assert_equal "abc\n", buf
+      }
+    }
+  end
+
   def test_connect_and_close
     start_server(OpenSSL::SSL::VERIFY_NONE, true){|server, port|
       sock = TCPSocket.new("127.0.0.1", port)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]