summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-22 16:54:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-22 16:54:01 +0000
commitd7d779b59485113d65fff6cc8aaf0b4a20fb9025 (patch)
tree6502191cec9cf752cac9120af77fd0de53ab4a9f /ext/openssl
parente4d925bf3ae6adcabc597aaf286f3e655161a2f0 (diff)
* ext/openssl/ossl_ssl.c (ssl_npn_select_cb): explicitly raise error
in ext/openssl instead of OpenSSL itself because LibreSSL silently truncate the selected protocol name by casting the length from int to unsigned char. [Bug #11369] Patch by Jeremy Evans <merch-redmine@jeremyevans.net> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_ssl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 3e6e164682..ae9f3ca8d7 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -599,9 +599,12 @@ ssl_npn_select_cb(SSL *s, unsigned char **out, unsigned char *outlen, const unsi
selected = rb_funcall(cb, rb_intern("call"), 1, protocols);
StringValue(selected);
+ i = RSTRING_LENINT(selected);
+ if (i < 1 || i >= 256) {
+ ossl_raise(eSSLError, "Selected protocol must have length 1..255");
+ }
*out = (unsigned char *) StringValuePtr(selected);
- *outlen = RSTRING_LENINT(selected);
-
+ *outlen = i;
return SSL_TLSEXT_ERR_OK;
}