Project

General

Profile

Actions

Bug #12660

closed

[PATCH] openssl: avoid undefined behavior on empty SSL_write

Added by normalperson (Eric Wong) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:76751]

Description

SSL_write(3ssl) manpage has this in the WARNINGS section:

   When calling SSL_write() with num=0 bytes to be sent the
   behaviour is undefined.

And indeed, the new test case demonstrates failures when
empty strings are used. So, match the behavior of IO#write,
IO#write_nonblock, and IO#syswrite by returning zero, as the
OpenSSL::SSL::SSLSocket API already closely mimics the IO one.

  • ext/openssl/ossl_ssl.c (ossl_ssl_write_internal):
    avoid undefined behavior
  • test/openssl/test_pair.rb (test_write_zero): new test

Comments? Will commit in a week or so if no response.


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0