Merge remote-tracking branch 'ry/v0.8'
This commit is contained in:
commit
18beea4a3f
8
deps/v8/src/platform-solaris.cc
vendored
8
deps/v8/src/platform-solaris.cc
vendored
@ -125,12 +125,8 @@ const char* OS::LocalTimezone(double time) {
|
|||||||
|
|
||||||
|
|
||||||
double OS::LocalTimeOffset() {
|
double OS::LocalTimeOffset() {
|
||||||
// On Solaris, struct tm does not contain a tm_gmtoff field.
|
tzset();
|
||||||
time_t utc = time(NULL);
|
return -static_cast<double>(timezone * msPerSecond);
|
||||||
ASSERT(utc != -1);
|
|
||||||
struct tm* loc = localtime(&utc);
|
|
||||||
ASSERT(loc != NULL);
|
|
||||||
return static_cast<double>((mktime(loc) - utc) * msPerSecond);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4101,22 +4101,16 @@ class DiffieHellman : public ObjectWrap {
|
|||||||
|
|
||||||
int size = DH_compute_key(reinterpret_cast<unsigned char*>(data),
|
int size = DH_compute_key(reinterpret_cast<unsigned char*>(data),
|
||||||
key, diffieHellman->dh);
|
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) {
|
if (size == -1) {
|
||||||
int checkResult;
|
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")));
|
return ThrowException(Exception::Error(String::New("Invalid key")));
|
||||||
} else if (checkResult) {
|
} else if (checkResult) {
|
||||||
if (checkResult & DH_CHECK_PUBKEY_TOO_SMALL) {
|
if (checkResult & DH_CHECK_PUBKEY_TOO_SMALL) {
|
||||||
@ -4131,14 +4125,28 @@ class DiffieHellman : public ObjectWrap {
|
|||||||
} else {
|
} else {
|
||||||
return ThrowException(Exception::Error(String::New("Invalid key")));
|
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 {
|
} else {
|
||||||
if (args.Length() > 2 && args[2]->IsString()) {
|
outString = Encode(data, dataSize, BINARY);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
@ -449,7 +449,7 @@ v8::Handle<v8::Value> cTypeToValue(unsigned char val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
v8::Handle<v8::Value> cTypeToValue(char val) {
|
v8::Handle<v8::Value> cTypeToValue(signed char val) {
|
||||||
return v8::Integer::New(val);
|
return v8::Integer::New(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ unsigned char valueToCType(v8::Handle<v8::Value> value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
char valueToCType(v8::Handle<v8::Value> value) {
|
signed char valueToCType(v8::Handle<v8::Value> value) {
|
||||||
return value->Int32Value();
|
return value->Int32Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ class DataView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static v8::Handle<v8::Value> getInt8(const v8::Arguments& args) {
|
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) {
|
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) {
|
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) {
|
static v8::Handle<v8::Value> setUint16(const v8::Arguments& args) {
|
||||||
|
@ -563,6 +563,10 @@ var secret3 = dh3.computeSecret(key2, 'hex', 'base64');
|
|||||||
|
|
||||||
assert.equal(secret1, secret3);
|
assert.equal(secret1, secret3);
|
||||||
|
|
||||||
|
assert.throws(function() {
|
||||||
|
dh3.computeSecret('');
|
||||||
|
}, /key is too small/i);
|
||||||
|
|
||||||
// https://github.com/joyent/node/issues/2338
|
// https://github.com/joyent/node/issues/2338
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
|
var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
|
||||||
|
@ -174,3 +174,11 @@ uint8c.set(1, 260);
|
|||||||
|
|
||||||
assert.equal(uint8c[0], 0);
|
assert.equal(uint8c[0], 0);
|
||||||
assert.equal(uint8c[1], 255);
|
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…
x
Reference in New Issue
Block a user