Skip to content

Commit

Permalink
Catch non-bytestrings from ALPN callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Apr 12, 2015
1 parent 8c0c966 commit 3e9f152
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from errno import errorcode

from six import text_type as _text_type
from six import binary_type as _binary_type
from six import integer_types as integer_types
from six import int2byte, indexbytes

Expand Down Expand Up @@ -1007,6 +1008,9 @@ def wrapper(ssl, out, outlen, in_, inlen, arg):
# Call the callback
outstr = callback(conn, protolist)

if not isinstance(outstr, _binary_type):
raise TypeError("ALPN callback must return a bytestring.")

# Save our callback arguments on the connection object to make sure
# that they don't get freed before OpenSSL can use them. Then,
# return them in the appropriate output parameters.
Expand Down

0 comments on commit 3e9f152

Please sign in to comment.