From 335f20896aaf4a96b15e2fcc69b384ef3182f92c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 23 Nov 2012 23:53:15 +0100 Subject: [PATCH] crypto: allow negative numbers in setOptions() OR'ing together two large values, like `SSL_OP_ALL | SSL_OP_NO_TICKET`, produces a negative number. To wit: assert((0x80000000 | 0x4000) === -0x7fffc000); // true assert((0x80000000 | 0x4000) === 0x80004000); // false! It's easy to work around by doing a logical shift, like this: assert((0x80000000 | 0x4000) >>> 0 === 0x80004000); // true But that's not very intuitive. Let's be more lenient in what we accept. --- src/node_crypto.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index ac90259e10a..f41b2d5a8c6 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -580,13 +580,11 @@ Handle SecureContext::SetOptions(const Arguments& args) { SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); - if (args.Length() != 1 || !args[0]->IsUint32()) { + if (args.Length() != 1 || !args[0]->IntegerValue()) { return ThrowException(Exception::TypeError(String::New("Bad parameter"))); } - unsigned int opts = args[0]->Uint32Value(); - - SSL_CTX_set_options(sc->ctx_, opts); + SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue()); return True(); }