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.
pull/24504/head
Ben Noordhuis 2012-11-23 23:53:15 +01:00
parent 8d2753c141
commit 335f20896a
1 changed files with 2 additions and 4 deletions

View File

@ -580,13 +580,11 @@ Handle<Value> SecureContext::SetOptions(const Arguments& args) {
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")));
}
unsigned int opts = args[0]->Uint32Value();
SSL_CTX_set_options(sc->ctx_, opts);
SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue());
return True();
}