Browse Source

Merge remote-tracking branch 'ry/v0.8'

v0.9.3-release
isaacs 12 years ago
parent
commit
18beea4a3f
  1. 8
      deps/v8/src/platform-solaris.cc
  2. 48
      src/node_crypto.cc
  3. 8
      src/v8_typed_array.cc
  4. 4
      test/simple/test-crypto.js
  5. 8
      test/simple/test-typed-arrays.js

8
deps/v8/src/platform-solaris.cc

@ -125,12 +125,8 @@ const char* OS::LocalTimezone(double time) {
double OS::LocalTimeOffset() {
// On Solaris, struct tm does not contain a tm_gmtoff field.
time_t utc = time(NULL);
ASSERT(utc != -1);
struct tm* loc = localtime(&utc);
ASSERT(loc != NULL);
return static_cast<double>((mktime(loc) - utc) * msPerSecond);
tzset();
return -static_cast<double>(timezone * msPerSecond);
}

48
src/node_crypto.cc

@ -4101,22 +4101,16 @@ class DiffieHellman : public ObjectWrap {
int size = DH_compute_key(reinterpret_cast<unsigned char*>(data),
key, diffieHellman->dh);
BN_free(key);
Local<Value> outString;
// DH_size returns number of bytes in a prime number
// DH_compute_key returns number of bytes in a remainder of exponent, which
// may have less bytes than a prime number. Therefore add 0-padding to the
// allocated buffer.
if (size != dataSize) {
assert(dataSize > size);
memset(data + size, 0, dataSize - size);
}
if (size == -1) {
int checkResult;
if (!DH_check_pub_key(diffieHellman->dh, key, &checkResult)) {
int checked;
checked = DH_check_pub_key(diffieHellman->dh, key, &checkResult);
BN_free(key);
delete[] data;
if (!checked) {
return ThrowException(Exception::Error(String::New("Invalid key")));
} else if (checkResult) {
if (checkResult & DH_CHECK_PUBKEY_TOO_SMALL) {
@ -4131,14 +4125,28 @@ class DiffieHellman : public ObjectWrap {
} else {
return ThrowException(Exception::Error(String::New("Invalid key")));
}
}
BN_free(key);
assert(size >= 0);
// DH_size returns number of bytes in a prime number
// DH_compute_key returns number of bytes in a remainder of exponent, which
// may have less bytes than a prime number. Therefore add 0-padding to the
// allocated buffer.
if (size != dataSize) {
assert(dataSize > size);
memset(data + size, 0, dataSize - size);
}
Local<Value> outString;
if (args.Length() > 2 && args[2]->IsString()) {
outString = EncodeWithEncoding(args[2], data, dataSize);
} else if (args.Length() > 1 && args[1]->IsString()) {
outString = EncodeWithEncoding(args[1], data, dataSize);
} else {
if (args.Length() > 2 && args[2]->IsString()) {
outString = EncodeWithEncoding(args[2], data, dataSize);
} else if (args.Length() > 1 && args[1]->IsString()) {
outString = EncodeWithEncoding(args[1], data, dataSize);
} else {
outString = Encode(data, dataSize, BINARY);
}
outString = Encode(data, dataSize, BINARY);
}
delete[] data;

8
src/v8_typed_array.cc

@ -449,7 +449,7 @@ v8::Handle<v8::Value> cTypeToValue(unsigned char val) {
}
template <>
v8::Handle<v8::Value> cTypeToValue(char val) {
v8::Handle<v8::Value> cTypeToValue(signed char val) {
return v8::Integer::New(val);
}
@ -495,7 +495,7 @@ unsigned char valueToCType(v8::Handle<v8::Value> value) {
}
template <>
char valueToCType(v8::Handle<v8::Value> value) {
signed char valueToCType(v8::Handle<v8::Value> value) {
return value->Int32Value();
}
@ -709,7 +709,7 @@ class DataView {
}
static v8::Handle<v8::Value> getInt8(const v8::Arguments& args) {
return getGeneric<char>(args);
return getGeneric<signed char>(args);
}
static v8::Handle<v8::Value> getUint16(const v8::Arguments& args) {
@ -741,7 +741,7 @@ class DataView {
}
static v8::Handle<v8::Value> setInt8(const v8::Arguments& args) {
return setGeneric<char>(args);
return setGeneric<signed char>(args);
}
static v8::Handle<v8::Value> setUint16(const v8::Arguments& args) {

4
test/simple/test-crypto.js

@ -563,6 +563,10 @@ var secret3 = dh3.computeSecret(key2, 'hex', 'base64');
assert.equal(secret1, secret3);
assert.throws(function() {
dh3.computeSecret('');
}, /key is too small/i);
// https://github.com/joyent/node/issues/2338
assert.throws(function() {
var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +

8
test/simple/test-typed-arrays.js

@ -174,3 +174,11 @@ uint8c.set(1, 260);
assert.equal(uint8c[0], 0);
assert.equal(uint8c[1], 255);
(function() {
var numbers = [];
for (var i = 128; i <= 255; ++i) numbers.push(i);
var array = new Uint8Array(numbers);
var view = new DataView(array.buffer);
for (var i = 128; i <= 255; ++i) assert.equal(view.getInt8(i - 128), i - 256);
})();

Loading…
Cancel
Save