Browse Source

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.
v0.9.4-release
Ben Noordhuis 12 years ago
parent
commit
335f20896a
  1. 6
      src/node_crypto.cc

6
src/node_crypto.cc

@ -580,13 +580,11 @@ Handle<Value> SecureContext::SetOptions(const Arguments& args) {
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
if (args.Length() != 1 || !args[0]->IsUint32()) { if (args.Length() != 1 || !args[0]->IntegerValue()) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
} }
unsigned int opts = args[0]->Uint32Value(); SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue());
SSL_CTX_set_options(sc->ctx_, opts);
return True(); return True();
} }

Loading…
Cancel
Save