cpplint: disallow if one-liners
This commit is contained in:
parent
7063c59b97
commit
2bc30f239b
@ -64,8 +64,10 @@ typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap;
|
|||||||
|
|
||||||
|
|
||||||
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
|
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
|
||||||
if (a->sock < b->sock) return -1;
|
if (a->sock < b->sock)
|
||||||
if (a->sock > b->sock) return 1;
|
return -1;
|
||||||
|
if (a->sock > b->sock)
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +812,8 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
String::Utf8Value name(string);
|
String::Utf8Value name(string);
|
||||||
int err = wrap->Send(*name);
|
int err = wrap->Send(*name);
|
||||||
if (err) delete wrap;
|
if (err)
|
||||||
|
delete wrap;
|
||||||
|
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
}
|
}
|
||||||
@ -974,7 +977,8 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
|
|||||||
NULL,
|
NULL,
|
||||||
&hints);
|
&hints);
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
if (err) delete req_wrap;
|
if (err)
|
||||||
|
delete req_wrap;
|
||||||
|
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,8 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
|
|||||||
FSEventWrap* wrap;
|
FSEventWrap* wrap;
|
||||||
NODE_UNWRAP_NO_ABORT(args.This(), FSEventWrap, wrap);
|
NODE_UNWRAP_NO_ABORT(args.This(), FSEventWrap, wrap);
|
||||||
|
|
||||||
if (wrap == NULL || wrap->initialized_ == false) return;
|
if (wrap == NULL || wrap->initialized_ == false)
|
||||||
|
return;
|
||||||
wrap->initialized_ = false;
|
wrap->initialized_ = false;
|
||||||
|
|
||||||
HandleWrap::Close(args);
|
HandleWrap::Close(args);
|
||||||
|
@ -72,7 +72,8 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
|
|||||||
NODE_UNWRAP_NO_ABORT(args.This(), HandleWrap, wrap);
|
NODE_UNWRAP_NO_ABORT(args.This(), HandleWrap, wrap);
|
||||||
|
|
||||||
// guard against uninitialized handle or double close
|
// guard against uninitialized handle or double close
|
||||||
if (wrap == NULL || wrap->handle__ == NULL) return;
|
if (wrap == NULL || wrap->handle__ == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
Environment* env = wrap->env();
|
Environment* env = wrap->env();
|
||||||
assert(!wrap->persistent().IsEmpty());
|
assert(!wrap->persistent().IsEmpty());
|
||||||
|
57
src/node.cc
57
src/node.cc
@ -164,7 +164,8 @@ ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
|
|||||||
|
|
||||||
|
|
||||||
void* ArrayBufferAllocator::Allocate(size_t length) {
|
void* ArrayBufferAllocator::Allocate(size_t length) {
|
||||||
if (length > kMaxLength) return NULL;
|
if (length > kMaxLength)
|
||||||
|
return NULL;
|
||||||
return new char[length];
|
return new char[length];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +840,8 @@ Local<Value> WinapiErrnoException(int errorno,
|
|||||||
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
|
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
|
||||||
Environment* env = Environment::GetCurrent(args.GetIsolate());
|
Environment* env = Environment::GetCurrent(args.GetIsolate());
|
||||||
|
|
||||||
if (env->using_domains()) return;
|
if (env->using_domains())
|
||||||
|
return;
|
||||||
env->set_using_domains(true);
|
env->set_using_domains(true);
|
||||||
|
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
@ -1122,7 +1124,8 @@ Handle<Value> MakeDomainCallback(const Handle<Object> object,
|
|||||||
enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
|
enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (!encoding_v->IsString()) return _default;
|
if (!encoding_v->IsString())
|
||||||
|
return _default;
|
||||||
|
|
||||||
String::Utf8Value encoding(encoding_v);
|
String::Utf8Value encoding(encoding_v);
|
||||||
|
|
||||||
@ -1203,7 +1206,8 @@ void DisplayExceptionLine(Handle<Message> message) {
|
|||||||
// then we want to show the original failure, not the secondary one.
|
// then we want to show the original failure, not the secondary one.
|
||||||
static bool displayed_error = false;
|
static bool displayed_error = false;
|
||||||
|
|
||||||
if (displayed_error) return;
|
if (displayed_error)
|
||||||
|
return;
|
||||||
displayed_error = true;
|
displayed_error = true;
|
||||||
|
|
||||||
uv_tty_reset_mode();
|
uv_tty_reset_mode();
|
||||||
@ -1339,7 +1343,8 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
QUEUE_FOREACH(q, &req_wrap_queue) {
|
QUEUE_FOREACH(q, &req_wrap_queue) {
|
||||||
ReqWrap<uv_req_t>* w = container_of(q, ReqWrap<uv_req_t>, req_wrap_queue_);
|
ReqWrap<uv_req_t>* w = container_of(q, ReqWrap<uv_req_t>, req_wrap_queue_);
|
||||||
if (w->persistent().IsEmpty()) continue;
|
if (w->persistent().IsEmpty())
|
||||||
|
continue;
|
||||||
ary->Set(i++, w->object());
|
ary->Set(i++, w->object());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1360,10 +1365,12 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
QUEUE_FOREACH(q, &handle_wrap_queue) {
|
QUEUE_FOREACH(q, &handle_wrap_queue) {
|
||||||
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
|
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
|
||||||
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
|
if (w->persistent().IsEmpty() || (w->flags_ & HandleWrap::kUnref))
|
||||||
|
continue;
|
||||||
Local<Object> object = w->object();
|
Local<Object> object = w->object();
|
||||||
Local<Value> owner = object->Get(owner_sym);
|
Local<Value> owner = object->Get(owner_sym);
|
||||||
if (owner->IsUndefined()) owner = object;
|
if (owner->IsUndefined())
|
||||||
|
owner = object;
|
||||||
ary->Set(i++, owner);
|
ary->Set(i++, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1622,7 +1629,8 @@ static void GetGroups(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
for (int i = 0; i < ngroups; i++) {
|
for (int i = 0; i < ngroups; i++) {
|
||||||
groups_list->Set(i, Integer::New(groups[i], node_isolate));
|
groups_list->Set(i, Integer::New(groups[i], node_isolate));
|
||||||
if (groups[i] == egid) seen_egid = true;
|
if (groups[i] == egid)
|
||||||
|
seen_egid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] groups;
|
delete[] groups;
|
||||||
@ -1697,7 +1705,8 @@ static void InitGroups(const FunctionCallbackInfo<Value>& args) {
|
|||||||
extra_group = gid_by_name(args[1]);
|
extra_group = gid_by_name(args[1]);
|
||||||
|
|
||||||
if (extra_group == gid_not_found) {
|
if (extra_group == gid_not_found) {
|
||||||
if (must_free) free(user);
|
if (must_free)
|
||||||
|
free(user);
|
||||||
return ThrowError("initgroups extra group not found");
|
return ThrowError("initgroups extra group not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1724,7 +1733,8 @@ void Exit(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void Uptime(const FunctionCallbackInfo<Value>& args) {
|
static void Uptime(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
double uptime;
|
double uptime;
|
||||||
if (uv_uptime(&uptime)) return;
|
if (uv_uptime(&uptime))
|
||||||
|
return;
|
||||||
args.GetReturnValue().Set(uptime - prog_start_time);
|
args.GetReturnValue().Set(uptime - prog_start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,7 +1881,8 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|||||||
* look for foo_bar_module, not foo-bar_module.
|
* look for foo_bar_module, not foo-bar_module.
|
||||||
*/
|
*/
|
||||||
for (pos = symbol; *pos != '\0'; ++pos) {
|
for (pos = symbol; *pos != '\0'; ++pos) {
|
||||||
if (*pos == '-') *pos = '_';
|
if (*pos == '-')
|
||||||
|
*pos = '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
node_module_struct *mod;
|
node_module_struct *mod;
|
||||||
@ -2105,7 +2116,8 @@ static void EnvQuery(Local<String> property,
|
|||||||
int32_t rc = -1; // Not found unless proven otherwise.
|
int32_t rc = -1; // Not found unless proven otherwise.
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
String::Utf8Value key(property);
|
String::Utf8Value key(property);
|
||||||
if (getenv(*key)) rc = 0;
|
if (getenv(*key))
|
||||||
|
rc = 0;
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
String::Value key(property);
|
String::Value key(property);
|
||||||
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
|
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
|
||||||
@ -2120,7 +2132,8 @@ static void EnvQuery(Local<String> property,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (rc != -1) info.GetReturnValue().Set(rc);
|
if (rc != -1)
|
||||||
|
info.GetReturnValue().Set(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2131,7 +2144,8 @@ static void EnvDeleter(Local<String> property,
|
|||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
String::Utf8Value key(property);
|
String::Utf8Value key(property);
|
||||||
rc = getenv(*key) != NULL;
|
rc = getenv(*key) != NULL;
|
||||||
if (rc) unsetenv(*key);
|
if (rc)
|
||||||
|
unsetenv(*key);
|
||||||
#else
|
#else
|
||||||
String::Value key(property);
|
String::Value key(property);
|
||||||
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
|
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
|
||||||
@ -2150,7 +2164,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
int size = 0;
|
int size = 0;
|
||||||
while (environ[size]) size++;
|
while (environ[size])
|
||||||
|
size++;
|
||||||
|
|
||||||
Local<Array> env = Array::New(size);
|
Local<Array> env = Array::New(size);
|
||||||
|
|
||||||
@ -2166,7 +2181,8 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
|
|||||||
}
|
}
|
||||||
#else // _WIN32
|
#else // _WIN32
|
||||||
WCHAR* environment = GetEnvironmentStringsW();
|
WCHAR* environment = GetEnvironmentStringsW();
|
||||||
if (environment == NULL) return; // This should not happen.
|
if (environment == NULL)
|
||||||
|
return; // This should not happen.
|
||||||
Local<Array> env = Array::New();
|
Local<Array> env = Array::New();
|
||||||
WCHAR* p = environment;
|
WCHAR* p = environment;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -2394,7 +2410,8 @@ void SetupProcessObject(Environment* env,
|
|||||||
if ('0' <= c && c <= '9') {
|
if ('0' <= c && c <= '9') {
|
||||||
for (j = i + 1; j < l; j++) {
|
for (j = i + 1; j < l; j++) {
|
||||||
c = OPENSSL_VERSION_TEXT[j];
|
c = OPENSSL_VERSION_TEXT[j];
|
||||||
if (c == ' ') break;
|
if (c == ' ')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2671,7 +2688,8 @@ static void ParseDebugOpt(const char* arg) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(stderr, "Bad debug option.\n");
|
fprintf(stderr, "Bad debug option.\n");
|
||||||
if (p) fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");
|
if (p)
|
||||||
|
fprintf(stderr, "Debug port must be in range 1025 to 65535.\n");
|
||||||
|
|
||||||
PrintHelp();
|
PrintHelp();
|
||||||
exit(12);
|
exit(12);
|
||||||
@ -2929,7 +2947,8 @@ static int RegisterDebugSignalHandler() {
|
|||||||
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
|
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
|
||||||
// If we caught a SIGUSR1 during the bootstrap process, re-raise it
|
// If we caught a SIGUSR1 during the bootstrap process, re-raise it
|
||||||
// now that the debugger infrastructure is in place.
|
// now that the debugger infrastructure is in place.
|
||||||
if (caught_early_debug_signal) raise(SIGUSR1);
|
if (caught_early_debug_signal)
|
||||||
|
raise(SIGUSR1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif // __POSIX__
|
#endif // __POSIX__
|
||||||
|
@ -471,7 +471,8 @@ void ReadFloatGeneric(const FunctionCallbackInfo<Value>& args) {
|
|||||||
const void* data = args.This()->GetIndexedPropertiesExternalArrayData();
|
const void* data = args.This()->GetIndexedPropertiesExternalArrayData();
|
||||||
const char* ptr = static_cast<const char*>(data) + offset;
|
const char* ptr = static_cast<const char*>(data) + offset;
|
||||||
memcpy(na.bytes, ptr, sizeof(na.bytes));
|
memcpy(na.bytes, ptr, sizeof(na.bytes));
|
||||||
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
|
if (endianness != GetEndianness())
|
||||||
|
Swizzle(na.bytes, sizeof(na.bytes));
|
||||||
|
|
||||||
args.GetReturnValue().Set(na.val);
|
args.GetReturnValue().Set(na.val);
|
||||||
}
|
}
|
||||||
@ -525,7 +526,8 @@ uint32_t WriteFloatGeneric(const FunctionCallbackInfo<Value>& args) {
|
|||||||
union NoAlias na = { val };
|
union NoAlias na = { val };
|
||||||
void* data = args.This()->GetIndexedPropertiesExternalArrayData();
|
void* data = args.This()->GetIndexedPropertiesExternalArrayData();
|
||||||
char* ptr = static_cast<char*>(data) + offset;
|
char* ptr = static_cast<char*>(data) + offset;
|
||||||
if (endianness != GetEndianness()) Swizzle(na.bytes, sizeof(na.bytes));
|
if (endianness != GetEndianness())
|
||||||
|
Swizzle(na.bytes, sizeof(na.bytes));
|
||||||
memcpy(ptr, na.bytes, sizeof(na.bytes));
|
memcpy(ptr, na.bytes, sizeof(na.bytes));
|
||||||
return offset + sizeof(na.bytes);
|
return offset + sizeof(na.bytes);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,8 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// Caller responsible for BIO_free_all-ing the returned object.
|
// Caller responsible for BIO_free_all-ing the returned object.
|
||||||
static BIO* LoadBIO(Handle<Value> v) {
|
static BIO* LoadBIO(Handle<Value> v) {
|
||||||
BIO* bio = NodeBIO::New();
|
BIO* bio = NodeBIO::New();
|
||||||
if (!bio) return NULL;
|
if (!bio)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
@ -338,7 +339,8 @@ static X509* LoadX509(Handle<Value> v) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
BIO *bio = LoadBIO(v);
|
BIO *bio = LoadBIO(v);
|
||||||
if (!bio) return NULL;
|
if (!bio)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
X509 * x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
|
X509 * x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
|
||||||
if (!x509) {
|
if (!x509) {
|
||||||
@ -365,7 +367,8 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BIO *bio = LoadBIO(args[0]);
|
BIO *bio = LoadBIO(args[0]);
|
||||||
if (!bio) return;
|
if (!bio)
|
||||||
|
return;
|
||||||
|
|
||||||
String::Utf8Value passphrase(args[1]);
|
String::Utf8Value passphrase(args[1]);
|
||||||
|
|
||||||
@ -448,7 +451,8 @@ int SSL_CTX_use_certificate_chain(SSL_CTX *ctx, BIO *in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (x != NULL) X509_free(x);
|
if (x != NULL)
|
||||||
|
X509_free(x);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +467,8 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BIO* bio = LoadBIO(args[0]);
|
BIO* bio = LoadBIO(args[0]);
|
||||||
if (!bio) return;
|
if (!bio)
|
||||||
|
return;
|
||||||
|
|
||||||
int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio);
|
int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio);
|
||||||
|
|
||||||
@ -495,7 +500,8 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
X509* x509 = LoadX509(args[0]);
|
X509* x509 = LoadX509(args[0]);
|
||||||
if (!x509) return;
|
if (!x509)
|
||||||
|
return;
|
||||||
|
|
||||||
X509_STORE_add_cert(sc->ca_store_, x509);
|
X509_STORE_add_cert(sc->ca_store_, x509);
|
||||||
SSL_CTX_add_client_CA(sc->ctx_, x509);
|
SSL_CTX_add_client_CA(sc->ctx_, x509);
|
||||||
@ -521,7 +527,8 @@ void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
|
|||||||
(void) &clear_error_on_return; // Silence compiler warning.
|
(void) &clear_error_on_return; // Silence compiler warning.
|
||||||
|
|
||||||
BIO *bio = LoadBIO(args[0]);
|
BIO *bio = LoadBIO(args[0]);
|
||||||
if (!bio) return;
|
if (!bio)
|
||||||
|
return;
|
||||||
|
|
||||||
X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL);
|
X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL);
|
||||||
|
|
||||||
@ -619,7 +626,8 @@ void SecureContext::SetSessionIdContext(
|
|||||||
unsigned int sid_ctx_len = sessionIdContext.length();
|
unsigned int sid_ctx_len = sessionIdContext.length();
|
||||||
|
|
||||||
int r = SSL_CTX_set_session_id_context(sc->ctx_, sid_ctx, sid_ctx_len);
|
int r = SSL_CTX_set_session_id_context(sc->ctx_, sid_ctx, sid_ctx_len);
|
||||||
if (r == 1) return;
|
if (r == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
BIO* bio;
|
BIO* bio;
|
||||||
BUF_MEM* mem;
|
BUF_MEM* mem;
|
||||||
@ -1398,7 +1406,8 @@ void Connection::OnClientHelloParseEnd(void* arg) {
|
|||||||
|
|
||||||
|
|
||||||
int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
|
int Connection::HandleBIOError(BIO *bio, const char* func, int rv) {
|
||||||
if (rv >= 0) return rv;
|
if (rv >= 0)
|
||||||
|
return rv;
|
||||||
|
|
||||||
int retry = BIO_should_retry(bio);
|
int retry = BIO_should_retry(bio);
|
||||||
(void) retry; // unused if !defined(SSL_PRINT_DEBUG)
|
(void) retry; // unused if !defined(SSL_PRINT_DEBUG)
|
||||||
@ -1722,7 +1731,8 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
} else {
|
} else {
|
||||||
bool reject_unauthorized = args[3]->BooleanValue();
|
bool reject_unauthorized = args[3]->BooleanValue();
|
||||||
verify_mode = SSL_VERIFY_PEER;
|
verify_mode = SSL_VERIFY_PEER;
|
||||||
if (reject_unauthorized) verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
|
if (reject_unauthorized)
|
||||||
|
verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Note request_cert and reject_unauthorized are ignored for clients.
|
// Note request_cert and reject_unauthorized are ignored for clients.
|
||||||
@ -2197,7 +2207,8 @@ bool CipherBase::Update(const char* data,
|
|||||||
int len,
|
int len,
|
||||||
unsigned char** out,
|
unsigned char** out,
|
||||||
int* out_len) {
|
int* out_len) {
|
||||||
if (!initialised_) return 0;
|
if (!initialised_)
|
||||||
|
return 0;
|
||||||
*out_len = len + EVP_CIPHER_CTX_block_size(&ctx_);
|
*out_len = len + EVP_CIPHER_CTX_block_size(&ctx_);
|
||||||
*out = new unsigned char[*out_len];
|
*out = new unsigned char[*out_len];
|
||||||
return EVP_CipherUpdate(&ctx_,
|
return EVP_CipherUpdate(&ctx_,
|
||||||
@ -2243,14 +2254,16 @@ void CipherBase::Update(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Local<Object> buf = Buffer::New(env, reinterpret_cast<char*>(out), out_len);
|
Local<Object> buf = Buffer::New(env, reinterpret_cast<char*>(out), out_len);
|
||||||
if (out) delete[] out;
|
if (out)
|
||||||
|
delete[] out;
|
||||||
|
|
||||||
args.GetReturnValue().Set(buf);
|
args.GetReturnValue().Set(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CipherBase::SetAutoPadding(bool auto_padding) {
|
bool CipherBase::SetAutoPadding(bool auto_padding) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
return EVP_CIPHER_CTX_set_padding(&ctx_, auto_padding);
|
return EVP_CIPHER_CTX_set_padding(&ctx_, auto_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2263,7 +2276,8 @@ void CipherBase::SetAutoPadding(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
bool CipherBase::Final(unsigned char** out, int *out_len) {
|
bool CipherBase::Final(unsigned char** out, int *out_len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
|
|
||||||
*out = new unsigned char[EVP_CIPHER_CTX_block_size(&ctx_)];
|
*out = new unsigned char[EVP_CIPHER_CTX_block_size(&ctx_)];
|
||||||
bool r = EVP_CipherFinal_ex(&ctx_, *out, out_len);
|
bool r = EVP_CipherFinal_ex(&ctx_, *out, out_len);
|
||||||
@ -2290,7 +2304,8 @@ void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
|
|||||||
delete[] out_value;
|
delete[] out_value;
|
||||||
out_value = NULL;
|
out_value = NULL;
|
||||||
out_len = 0;
|
out_len = 0;
|
||||||
if (!r) return ThrowCryptoTypeError(ERR_get_error());
|
if (!r)
|
||||||
|
return ThrowCryptoTypeError(ERR_get_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(
|
args.GetReturnValue().Set(
|
||||||
@ -2353,7 +2368,8 @@ void Hmac::HmacInit(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
bool Hmac::HmacUpdate(const char* data, int len) {
|
bool Hmac::HmacUpdate(const char* data, int len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
HMAC_Update(&ctx_, reinterpret_cast<const unsigned char*>(data), len);
|
HMAC_Update(&ctx_, reinterpret_cast<const unsigned char*>(data), len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2391,7 +2407,8 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) {
|
bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
*md_value = new unsigned char[EVP_MAX_MD_SIZE];
|
*md_value = new unsigned char[EVP_MAX_MD_SIZE];
|
||||||
HMAC_Final(&ctx_, *md_value, md_len);
|
HMAC_Final(&ctx_, *md_value, md_len);
|
||||||
HMAC_CTX_cleanup(&ctx_);
|
HMAC_CTX_cleanup(&ctx_);
|
||||||
@ -2457,7 +2474,8 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
bool Hash::HashInit(const char* hash_type) {
|
bool Hash::HashInit(const char* hash_type) {
|
||||||
assert(md_ == NULL);
|
assert(md_ == NULL);
|
||||||
md_ = EVP_get_digestbyname(hash_type);
|
md_ = EVP_get_digestbyname(hash_type);
|
||||||
if (md_ == NULL) return false;
|
if (md_ == NULL)
|
||||||
|
return false;
|
||||||
EVP_MD_CTX_init(&mdctx_);
|
EVP_MD_CTX_init(&mdctx_);
|
||||||
EVP_DigestInit_ex(&mdctx_, md_, NULL);
|
EVP_DigestInit_ex(&mdctx_, md_, NULL);
|
||||||
initialised_ = true;
|
initialised_ = true;
|
||||||
@ -2466,7 +2484,8 @@ bool Hash::HashInit(const char* hash_type) {
|
|||||||
|
|
||||||
|
|
||||||
bool Hash::HashUpdate(const char* data, int len) {
|
bool Hash::HashUpdate(const char* data, int len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
EVP_DigestUpdate(&mdctx_, data, len);
|
EVP_DigestUpdate(&mdctx_, data, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2577,7 +2596,8 @@ void Sign::SignInit(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
bool Sign::SignUpdate(const char* data, int len) {
|
bool Sign::SignUpdate(const char* data, int len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
EVP_SignUpdate(&mdctx_, data, len);
|
EVP_SignUpdate(&mdctx_, data, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2618,15 +2638,18 @@ bool Sign::SignFinal(unsigned char** md_value,
|
|||||||
unsigned int *md_len,
|
unsigned int *md_len,
|
||||||
const char* key_pem,
|
const char* key_pem,
|
||||||
int key_pem_len) {
|
int key_pem_len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
|
|
||||||
BIO* bp = NULL;
|
BIO* bp = NULL;
|
||||||
EVP_PKEY* pkey = NULL;
|
EVP_PKEY* pkey = NULL;
|
||||||
bp = BIO_new(BIO_s_mem());
|
bp = BIO_new(BIO_s_mem());
|
||||||
if (!BIO_write(bp, key_pem, key_pem_len)) return false;
|
if (!BIO_write(bp, key_pem, key_pem_len))
|
||||||
|
return false;
|
||||||
|
|
||||||
pkey = PEM_read_bio_PrivateKey(bp, NULL, NULL, NULL);
|
pkey = PEM_read_bio_PrivateKey(bp, NULL, NULL, NULL);
|
||||||
if (pkey == NULL) return 0;
|
if (pkey == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
EVP_SignFinal(&mdctx_, *md_value, md_len, pkey);
|
EVP_SignFinal(&mdctx_, *md_value, md_len, pkey);
|
||||||
EVP_MD_CTX_cleanup(&mdctx_);
|
EVP_MD_CTX_cleanup(&mdctx_);
|
||||||
@ -2719,7 +2742,8 @@ void Verify::VerifyInit(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
bool Verify::VerifyUpdate(const char* data, int len) {
|
bool Verify::VerifyUpdate(const char* data, int len) {
|
||||||
if (!initialised_) return false;
|
if (!initialised_)
|
||||||
|
return false;
|
||||||
EVP_VerifyUpdate(&mdctx_, data, len);
|
EVP_VerifyUpdate(&mdctx_, data, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2791,7 +2815,8 @@ bool Verify::VerifyFinal(const char* key_pem,
|
|||||||
RSA* rsa = PEM_read_bio_RSAPublicKey(bp, NULL, NULL, NULL);
|
RSA* rsa = PEM_read_bio_RSAPublicKey(bp, NULL, NULL, NULL);
|
||||||
if (rsa) {
|
if (rsa) {
|
||||||
pkey = EVP_PKEY_new();
|
pkey = EVP_PKEY_new();
|
||||||
if (pkey) EVP_PKEY_set1_RSA(pkey, rsa);
|
if (pkey)
|
||||||
|
EVP_PKEY_set1_RSA(pkey, rsa);
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
}
|
}
|
||||||
if (pkey == NULL)
|
if (pkey == NULL)
|
||||||
@ -2906,7 +2931,8 @@ bool DiffieHellman::Init(int primeLength) {
|
|||||||
dh = DH_new();
|
dh = DH_new();
|
||||||
DH_generate_parameters_ex(dh, primeLength, DH_GENERATOR_2, 0);
|
DH_generate_parameters_ex(dh, primeLength, DH_GENERATOR_2, 0);
|
||||||
bool result = VerifyContext();
|
bool result = VerifyContext();
|
||||||
if (!result) return false;
|
if (!result)
|
||||||
|
return false;
|
||||||
initialised_ = true;
|
initialised_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2916,9 +2942,11 @@ bool DiffieHellman::Init(const char* p, int p_len) {
|
|||||||
dh = DH_new();
|
dh = DH_new();
|
||||||
dh->p = BN_bin2bn(reinterpret_cast<const unsigned char*>(p), p_len, 0);
|
dh->p = BN_bin2bn(reinterpret_cast<const unsigned char*>(p), p_len, 0);
|
||||||
dh->g = BN_new();
|
dh->g = BN_new();
|
||||||
if (!BN_set_word(dh->g, 2)) return false;
|
if (!BN_set_word(dh->g, 2))
|
||||||
|
return false;
|
||||||
bool result = VerifyContext();
|
bool result = VerifyContext();
|
||||||
if (!result) return false;
|
if (!result)
|
||||||
|
return false;
|
||||||
initialised_ = true;
|
initialised_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3211,11 +3239,16 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
bool DiffieHellman::VerifyContext() {
|
bool DiffieHellman::VerifyContext() {
|
||||||
int codes;
|
int codes;
|
||||||
if (!DH_check(dh, &codes)) return false;
|
if (!DH_check(dh, &codes))
|
||||||
if (codes & DH_CHECK_P_NOT_SAFE_PRIME) return false;
|
return false;
|
||||||
if (codes & DH_CHECK_P_NOT_PRIME) return false;
|
if (codes & DH_CHECK_P_NOT_SAFE_PRIME)
|
||||||
if (codes & DH_UNABLE_TO_CHECK_GENERATOR) return false;
|
return false;
|
||||||
if (codes & DH_NOT_SUITABLE_GENERATOR) return false;
|
if (codes & DH_CHECK_P_NOT_PRIME)
|
||||||
|
return false;
|
||||||
|
if (codes & DH_UNABLE_TO_CHECK_GENERATOR)
|
||||||
|
return false;
|
||||||
|
if (codes & DH_NOT_SUITABLE_GENERATOR)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,8 @@ class CipherBase : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~CipherBase() {
|
~CipherBase() {
|
||||||
if (!initialised_) return;
|
if (!initialised_)
|
||||||
|
return;
|
||||||
EVP_CIPHER_CTX_cleanup(&ctx_);
|
EVP_CIPHER_CTX_cleanup(&ctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +387,8 @@ class Hmac : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Hmac() {
|
~Hmac() {
|
||||||
if (!initialised_) return;
|
if (!initialised_)
|
||||||
|
return;
|
||||||
HMAC_CTX_cleanup(&ctx_);
|
HMAC_CTX_cleanup(&ctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +417,8 @@ class Hash : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Hash() {
|
~Hash() {
|
||||||
if (!initialised_) return;
|
if (!initialised_)
|
||||||
|
return;
|
||||||
EVP_MD_CTX_cleanup(&mdctx_);
|
EVP_MD_CTX_cleanup(&mdctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +452,8 @@ class Sign : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Sign() {
|
~Sign() {
|
||||||
if (!initialised_) return;
|
if (!initialised_)
|
||||||
|
return;
|
||||||
EVP_MD_CTX_cleanup(&mdctx_);
|
EVP_MD_CTX_cleanup(&mdctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +487,8 @@ class Verify : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Verify() {
|
~Verify() {
|
||||||
if (!initialised_) return;
|
if (!initialised_)
|
||||||
|
return;
|
||||||
EVP_MD_CTX_cleanup(&mdctx_);
|
EVP_MD_CTX_cleanup(&mdctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,8 @@ int NodeBIO::New(BIO* bio) {
|
|||||||
|
|
||||||
|
|
||||||
int NodeBIO::Free(BIO* bio) {
|
int NodeBIO::Free(BIO* bio) {
|
||||||
if (bio == NULL) return 0;
|
if (bio == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (bio->shutdown) {
|
if (bio->shutdown) {
|
||||||
if (bio->init && bio->ptr != NULL) {
|
if (bio->init && bio->ptr != NULL) {
|
||||||
@ -118,10 +119,12 @@ int NodeBIO::Gets(BIO* bio, char* out, int size) {
|
|||||||
int i = nbio->IndexOf('\n', size);
|
int i = nbio->IndexOf('\n', size);
|
||||||
|
|
||||||
// Include '\n'
|
// Include '\n'
|
||||||
if (i < size) i++;
|
if (i < size)
|
||||||
|
i++;
|
||||||
|
|
||||||
// Shift `i` a bit to NULL-terminate string later
|
// Shift `i` a bit to NULL-terminate string later
|
||||||
if (size == i) i--;
|
if (size == i)
|
||||||
|
i--;
|
||||||
|
|
||||||
// Flush read data
|
// Flush read data
|
||||||
nbio->Read(out, i);
|
nbio->Read(out, i);
|
||||||
|
180
src/node_file.cc
180
src/node_file.cc
@ -73,7 +73,8 @@ class FSReqWrap: public ReqWrap<uv_fs_t> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseEarly() {
|
void ReleaseEarly() {
|
||||||
if (data_ == NULL) return;
|
if (data_ == NULL)
|
||||||
|
return;
|
||||||
delete[] data_;
|
delete[] data_;
|
||||||
data_ = NULL;
|
data_ = NULL;
|
||||||
}
|
}
|
||||||
@ -255,7 +256,8 @@ struct fs_req_wrap {
|
|||||||
&req_wrap.req, \
|
&req_wrap.req, \
|
||||||
__VA_ARGS__, \
|
__VA_ARGS__, \
|
||||||
NULL); \
|
NULL); \
|
||||||
if (err < 0) return ThrowUVException(err, #func, NULL, path); \
|
if (err < 0) \
|
||||||
|
return ThrowUVException(err, #func, NULL, path); \
|
||||||
|
|
||||||
#define SYNC_REQ req_wrap.req
|
#define SYNC_REQ req_wrap.req
|
||||||
|
|
||||||
@ -304,7 +306,8 @@ Local<Object> BuildStatsObject(Environment* env, const uv_stat_t* s) {
|
|||||||
#define X(name) \
|
#define X(name) \
|
||||||
{ \
|
{ \
|
||||||
Local<Value> val = Integer::New(s->st_##name, node_isolate); \
|
Local<Value> val = Integer::New(s->st_##name, node_isolate); \
|
||||||
if (val.IsEmpty()) return Local<Object>(); \
|
if (val.IsEmpty()) \
|
||||||
|
return Local<Object>(); \
|
||||||
stats->Set(env->name ## _string(), val); \
|
stats->Set(env->name ## _string(), val); \
|
||||||
}
|
}
|
||||||
X(dev)
|
X(dev)
|
||||||
@ -321,7 +324,8 @@ Local<Object> BuildStatsObject(Environment* env, const uv_stat_t* s) {
|
|||||||
#define X(name) \
|
#define X(name) \
|
||||||
{ \
|
{ \
|
||||||
Local<Value> val = Number::New(static_cast<double>(s->st_##name)); \
|
Local<Value> val = Number::New(static_cast<double>(s->st_##name)); \
|
||||||
if (val.IsEmpty()) return Local<Object>(); \
|
if (val.IsEmpty()) \
|
||||||
|
return Local<Object>(); \
|
||||||
stats->Set(env->name ## _string(), val); \
|
stats->Set(env->name ## _string(), val); \
|
||||||
}
|
}
|
||||||
X(ino)
|
X(ino)
|
||||||
@ -336,7 +340,8 @@ Local<Object> BuildStatsObject(Environment* env, const uv_stat_t* s) {
|
|||||||
double msecs = static_cast<double>(s->st_##rec.tv_sec) * 1000; \
|
double msecs = static_cast<double>(s->st_##rec.tv_sec) * 1000; \
|
||||||
msecs += static_cast<double>(s->st_##rec.tv_nsec / 1000000); \
|
msecs += static_cast<double>(s->st_##rec.tv_nsec / 1000000); \
|
||||||
Local<Value> val = v8::Date::New(msecs); \
|
Local<Value> val = v8::Date::New(msecs); \
|
||||||
if (val.IsEmpty()) return Local<Object>(); \
|
if (val.IsEmpty()) \
|
||||||
|
return Local<Object>(); \
|
||||||
stats->Set(env->name ## _string(), val); \
|
stats->Set(env->name ## _string(), val); \
|
||||||
}
|
}
|
||||||
X(atime, atim)
|
X(atime, atim)
|
||||||
@ -351,8 +356,10 @@ Local<Object> BuildStatsObject(Environment* env, const uv_stat_t* s) {
|
|||||||
static void Stat(const FunctionCallbackInfo<Value>& args) {
|
static void Stat(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -368,8 +375,10 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void LStat(const FunctionCallbackInfo<Value>& args) {
|
static void LStat(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -404,10 +413,14 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("dest path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("src path required");
|
return TYPE_ERROR("dest path required");
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string");
|
if (len < 2)
|
||||||
if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string");
|
return TYPE_ERROR("src path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("dest path must be a string");
|
||||||
|
if (!args[1]->IsString())
|
||||||
|
return TYPE_ERROR("src path must be a string");
|
||||||
|
|
||||||
String::Utf8Value dest(args[0]);
|
String::Utf8Value dest(args[0]);
|
||||||
String::Utf8Value path(args[1]);
|
String::Utf8Value path(args[1]);
|
||||||
@ -435,10 +448,14 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("dest path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("src path required");
|
return TYPE_ERROR("dest path required");
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("dest path must be a string");
|
if (len < 2)
|
||||||
if (!args[1]->IsString()) return TYPE_ERROR("src path must be a string");
|
return TYPE_ERROR("src path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("dest path must be a string");
|
||||||
|
if (!args[1]->IsString())
|
||||||
|
return TYPE_ERROR("src path must be a string");
|
||||||
|
|
||||||
String::Utf8Value orig_path(args[0]);
|
String::Utf8Value orig_path(args[0]);
|
||||||
String::Utf8Value new_path(args[1]);
|
String::Utf8Value new_path(args[1]);
|
||||||
@ -453,8 +470,10 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void ReadLink(const FunctionCallbackInfo<Value>& args) {
|
static void ReadLink(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -472,10 +491,14 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("old path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("new path required");
|
return TYPE_ERROR("old path required");
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("old path must be a string");
|
if (len < 2)
|
||||||
if (!args[1]->IsString()) return TYPE_ERROR("new path must be a string");
|
return TYPE_ERROR("new path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("old path must be a string");
|
||||||
|
if (!args[1]->IsString())
|
||||||
|
return TYPE_ERROR("new path must be a string");
|
||||||
|
|
||||||
String::Utf8Value old_path(args[0]);
|
String::Utf8Value old_path(args[0]);
|
||||||
String::Utf8Value new_path(args[1]);
|
String::Utf8Value new_path(args[1]);
|
||||||
@ -541,8 +564,10 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void Unlink(const FunctionCallbackInfo<Value>& args) {
|
static void Unlink(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -556,8 +581,10 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void RMDir(const FunctionCallbackInfo<Value>& args) {
|
static void RMDir(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -588,8 +615,10 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void ReadDir(const FunctionCallbackInfo<Value>& args) {
|
static void ReadDir(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
if (args.Length() < 1) return TYPE_ERROR("path required");
|
if (args.Length() < 1)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("path required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
|
|
||||||
@ -622,12 +651,18 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("flags required");
|
return TYPE_ERROR("path required");
|
||||||
if (len < 3) return TYPE_ERROR("mode required");
|
if (len < 2)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("flags required");
|
||||||
if (!args[1]->IsInt32()) return TYPE_ERROR("flags must be an int");
|
if (len < 3)
|
||||||
if (!args[2]->IsInt32()) return TYPE_ERROR("mode must be an int");
|
return TYPE_ERROR("mode required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
if (!args[1]->IsInt32())
|
||||||
|
return TYPE_ERROR("flags must be an int");
|
||||||
|
if (!args[2]->IsInt32())
|
||||||
|
return TYPE_ERROR("mode must be an int");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
int flags = args[1]->Int32Value();
|
int flags = args[1]->Int32Value();
|
||||||
@ -727,7 +762,8 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
if (!cb->IsFunction()) {
|
if (!cb->IsFunction()) {
|
||||||
SYNC_CALL(write, NULL, fd, buf, len, pos)
|
SYNC_CALL(write, NULL, fd, buf, len, pos)
|
||||||
if (must_free) delete[] buf;
|
if (must_free)
|
||||||
|
delete[] buf;
|
||||||
return args.GetReturnValue().Set(SYNC_RESULT);
|
return args.GetReturnValue().Set(SYNC_RESULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,12 +896,18 @@ static void Chown(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("uid required");
|
return TYPE_ERROR("path required");
|
||||||
if (len < 3) return TYPE_ERROR("gid required");
|
if (len < 2)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("uid required");
|
||||||
if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int");
|
if (len < 3)
|
||||||
if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int");
|
return TYPE_ERROR("gid required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
if (!args[1]->IsUint32())
|
||||||
|
return TYPE_ERROR("uid must be an unsigned int");
|
||||||
|
if (!args[2]->IsUint32())
|
||||||
|
return TYPE_ERROR("gid must be an unsigned int");
|
||||||
|
|
||||||
String::Utf8Value path(args[0]);
|
String::Utf8Value path(args[0]);
|
||||||
uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value());
|
uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value());
|
||||||
@ -886,12 +928,18 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("fd required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("uid required");
|
return TYPE_ERROR("fd required");
|
||||||
if (len < 3) return TYPE_ERROR("gid required");
|
if (len < 2)
|
||||||
if (!args[0]->IsInt32()) return TYPE_ERROR("fd must be an int");
|
return TYPE_ERROR("uid required");
|
||||||
if (!args[1]->IsUint32()) return TYPE_ERROR("uid must be an unsigned int");
|
if (len < 3)
|
||||||
if (!args[2]->IsUint32()) return TYPE_ERROR("gid must be an unsigned int");
|
return TYPE_ERROR("gid required");
|
||||||
|
if (!args[0]->IsInt32())
|
||||||
|
return TYPE_ERROR("fd must be an int");
|
||||||
|
if (!args[1]->IsUint32())
|
||||||
|
return TYPE_ERROR("uid must be an unsigned int");
|
||||||
|
if (!args[2]->IsUint32())
|
||||||
|
return TYPE_ERROR("gid must be an unsigned int");
|
||||||
|
|
||||||
int fd = args[0]->Int32Value();
|
int fd = args[0]->Int32Value();
|
||||||
uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value());
|
uv_uid_t uid = static_cast<uv_uid_t>(args[1]->Uint32Value());
|
||||||
@ -909,12 +957,18 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("path required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("atime required");
|
return TYPE_ERROR("path required");
|
||||||
if (len < 3) return TYPE_ERROR("mtime required");
|
if (len < 2)
|
||||||
if (!args[0]->IsString()) return TYPE_ERROR("path must be a string");
|
return TYPE_ERROR("atime required");
|
||||||
if (!args[1]->IsNumber()) return TYPE_ERROR("atime must be a number");
|
if (len < 3)
|
||||||
if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number");
|
return TYPE_ERROR("mtime required");
|
||||||
|
if (!args[0]->IsString())
|
||||||
|
return TYPE_ERROR("path must be a string");
|
||||||
|
if (!args[1]->IsNumber())
|
||||||
|
return TYPE_ERROR("atime must be a number");
|
||||||
|
if (!args[2]->IsNumber())
|
||||||
|
return TYPE_ERROR("mtime must be a number");
|
||||||
|
|
||||||
const String::Utf8Value path(args[0]);
|
const String::Utf8Value path(args[0]);
|
||||||
const double atime = static_cast<double>(args[1]->NumberValue());
|
const double atime = static_cast<double>(args[1]->NumberValue());
|
||||||
@ -931,12 +985,18 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
|
|
||||||
int len = args.Length();
|
int len = args.Length();
|
||||||
if (len < 1) return TYPE_ERROR("fd required");
|
if (len < 1)
|
||||||
if (len < 2) return TYPE_ERROR("atime required");
|
return TYPE_ERROR("fd required");
|
||||||
if (len < 3) return TYPE_ERROR("mtime required");
|
if (len < 2)
|
||||||
if (!args[0]->IsInt32()) return TYPE_ERROR("fd must be an int");
|
return TYPE_ERROR("atime required");
|
||||||
if (!args[1]->IsNumber()) return TYPE_ERROR("atime must be a number");
|
if (len < 3)
|
||||||
if (!args[2]->IsNumber()) return TYPE_ERROR("mtime must be a number");
|
return TYPE_ERROR("mtime required");
|
||||||
|
if (!args[0]->IsInt32())
|
||||||
|
return TYPE_ERROR("fd must be an int");
|
||||||
|
if (!args[1]->IsNumber())
|
||||||
|
return TYPE_ERROR("atime must be a number");
|
||||||
|
if (!args[2]->IsNumber())
|
||||||
|
return TYPE_ERROR("mtime must be a number");
|
||||||
|
|
||||||
const int fd = args[0]->Int32Value();
|
const int fd = args[0]->Int32Value();
|
||||||
const double atime = static_cast<double>(args[1]->NumberValue());
|
const double atime = static_cast<double>(args[1]->NumberValue());
|
||||||
|
@ -417,7 +417,8 @@ class Parser : public WeakObject {
|
|||||||
parser->current_buffer_data_ = NULL;
|
parser->current_buffer_data_ = NULL;
|
||||||
|
|
||||||
// If there was an exception in one of the callbacks
|
// If there was an exception in one of the callbacks
|
||||||
if (parser->got_exception_) return;
|
if (parser->got_exception_)
|
||||||
|
return;
|
||||||
|
|
||||||
Local<Integer> nparsed_obj = Integer::New(nparsed, node_isolate);
|
Local<Integer> nparsed_obj = Integer::New(nparsed, node_isolate);
|
||||||
// If there was a parse error in one of the callbacks
|
// If there was a parse error in one of the callbacks
|
||||||
@ -449,7 +450,8 @@ class Parser : public WeakObject {
|
|||||||
|
|
||||||
int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0);
|
int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0);
|
||||||
|
|
||||||
if (parser->got_exception_) return;
|
if (parser->got_exception_)
|
||||||
|
return;
|
||||||
|
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_);
|
||||||
|
@ -91,7 +91,8 @@ inline static int snprintf(char* buf, unsigned int len, const char* fmt, ...) {
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
int n = _vsprintf_p(buf, len, fmt, ap);
|
int n = _vsprintf_p(buf, len, fmt, ap);
|
||||||
if (len) buf[len - 1] = '\0';
|
if (len)
|
||||||
|
buf[len - 1] = '\0';
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,8 @@ class NODE_EXTERN ObjectWrap {
|
|||||||
|
|
||||||
|
|
||||||
virtual ~ObjectWrap() {
|
virtual ~ObjectWrap() {
|
||||||
if (persistent().IsEmpty()) return;
|
if (persistent().IsEmpty())
|
||||||
|
return;
|
||||||
assert(persistent().IsNearDeath());
|
assert(persistent().IsNearDeath());
|
||||||
persistent().ClearWeak();
|
persistent().ClearWeak();
|
||||||
persistent().Dispose();
|
persistent().Dispose();
|
||||||
@ -117,7 +118,8 @@ class NODE_EXTERN ObjectWrap {
|
|||||||
assert(!persistent().IsEmpty());
|
assert(!persistent().IsEmpty());
|
||||||
assert(!persistent().IsWeak());
|
assert(!persistent().IsWeak());
|
||||||
assert(refs_ > 0);
|
assert(refs_ > 0);
|
||||||
if (--refs_ == 0) MakeWeak();
|
if (--refs_ == 0)
|
||||||
|
MakeWeak();
|
||||||
}
|
}
|
||||||
|
|
||||||
int refs_; // ro
|
int refs_; // ro
|
||||||
|
@ -115,7 +115,8 @@ static void GetOSRelease(const FunctionCallbackInfo<Value>& args) {
|
|||||||
OSVERSIONINFO info;
|
OSVERSIONINFO info;
|
||||||
|
|
||||||
info.dwOSVersionInfoSize = sizeof(info);
|
info.dwOSVersionInfoSize = sizeof(info);
|
||||||
if (GetVersionEx(&info) == 0) return;
|
if (GetVersionEx(&info) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
snprintf(release,
|
snprintf(release,
|
||||||
sizeof(release),
|
sizeof(release),
|
||||||
@ -136,7 +137,8 @@ static void GetCPUInfo(const FunctionCallbackInfo<Value>& args) {
|
|||||||
int count, i;
|
int count, i;
|
||||||
|
|
||||||
int err = uv_cpu_info(&cpu_infos, &count);
|
int err = uv_cpu_info(&cpu_infos, &count);
|
||||||
if (err) return;
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
Local<Array> cpus = Array::New();
|
Local<Array> cpus = Array::New();
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
@ -172,7 +174,8 @@ static void GetCPUInfo(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void GetFreeMemory(const FunctionCallbackInfo<Value>& args) {
|
static void GetFreeMemory(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
double amount = uv_get_free_memory();
|
double amount = uv_get_free_memory();
|
||||||
if (amount < 0) return;
|
if (amount < 0)
|
||||||
|
return;
|
||||||
args.GetReturnValue().Set(amount);
|
args.GetReturnValue().Set(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +183,8 @@ static void GetFreeMemory(const FunctionCallbackInfo<Value>& args) {
|
|||||||
static void GetTotalMemory(const FunctionCallbackInfo<Value>& args) {
|
static void GetTotalMemory(const FunctionCallbackInfo<Value>& args) {
|
||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
double amount = uv_get_total_memory();
|
double amount = uv_get_total_memory();
|
||||||
if (amount < 0) return;
|
if (amount < 0)
|
||||||
|
return;
|
||||||
args.GetReturnValue().Set(amount);
|
args.GetReturnValue().Set(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +193,8 @@ static void GetUptime(const FunctionCallbackInfo<Value>& args) {
|
|||||||
HandleScope scope(node_isolate);
|
HandleScope scope(node_isolate);
|
||||||
double uptime;
|
double uptime;
|
||||||
int err = uv_uptime(&uptime);
|
int err = uv_uptime(&uptime);
|
||||||
if (err == 0) args.GetReturnValue().Set(uptime);
|
if (err == 0)
|
||||||
|
args.GetReturnValue().Set(uptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,8 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
|
|||||||
const bool persistent = args[1]->BooleanValue();
|
const bool persistent = args[1]->BooleanValue();
|
||||||
const uint32_t interval = args[2]->Uint32Value();
|
const uint32_t interval = args[2]->Uint32Value();
|
||||||
|
|
||||||
if (!persistent) uv_unref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));
|
if (!persistent)
|
||||||
|
uv_unref(reinterpret_cast<uv_handle_t*>(wrap->watcher_));
|
||||||
uv_fs_poll_start(wrap->watcher_, Callback, *path, interval);
|
uv_fs_poll_start(wrap->watcher_, Callback, *path, interval);
|
||||||
wrap->ClearWeak();
|
wrap->ClearWeak();
|
||||||
}
|
}
|
||||||
@ -134,7 +135,8 @@ void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
|
|
||||||
void StatWatcher::Stop() {
|
void StatWatcher::Stop() {
|
||||||
if (!uv_is_active(reinterpret_cast<uv_handle_t*>(watcher_))) return;
|
if (!uv_is_active(reinterpret_cast<uv_handle_t*>(watcher_)))
|
||||||
|
return;
|
||||||
uv_fs_poll_stop(watcher_);
|
uv_fs_poll_stop(watcher_);
|
||||||
MakeWeak();
|
MakeWeak();
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,8 @@ class ZCtx : public WeakObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SetDictionary(ZCtx* ctx) {
|
static void SetDictionary(ZCtx* ctx) {
|
||||||
if (ctx->dictionary_ == NULL) return;
|
if (ctx->dictionary_ == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
ctx->err_ = Z_OK;
|
ctx->err_ = Z_OK;
|
||||||
|
|
||||||
|
@ -481,7 +481,8 @@ void StreamWrap::Shutdown(const FunctionCallbackInfo<Value>& args) {
|
|||||||
ShutdownWrap* req_wrap = new ShutdownWrap(env, req_wrap_obj);
|
ShutdownWrap* req_wrap = new ShutdownWrap(env, req_wrap_obj);
|
||||||
int err = wrap->callbacks()->DoShutdown(req_wrap, AfterShutdown);
|
int err = wrap->callbacks()->DoShutdown(req_wrap, AfterShutdown);
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
if (err) delete req_wrap;
|
if (err)
|
||||||
|
delete req_wrap;
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,26 +173,36 @@ size_t base64_decode(char* buf,
|
|||||||
while (src < srcEnd && dst < dstEnd) {
|
while (src < srcEnd && dst < dstEnd) {
|
||||||
int remaining = srcEnd - src;
|
int remaining = srcEnd - src;
|
||||||
|
|
||||||
while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--;
|
while (unbase64(*src) < 0 && src < srcEnd)
|
||||||
if (remaining == 0 || *src == '=') break;
|
src++, remaining--;
|
||||||
|
if (remaining == 0 || *src == '=')
|
||||||
|
break;
|
||||||
a = unbase64(*src++);
|
a = unbase64(*src++);
|
||||||
|
|
||||||
while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--;
|
while (unbase64(*src) < 0 && src < srcEnd)
|
||||||
if (remaining <= 1 || *src == '=') break;
|
src++, remaining--;
|
||||||
|
if (remaining <= 1 || *src == '=')
|
||||||
|
break;
|
||||||
b = unbase64(*src++);
|
b = unbase64(*src++);
|
||||||
|
|
||||||
*dst++ = (a << 2) | ((b & 0x30) >> 4);
|
*dst++ = (a << 2) | ((b & 0x30) >> 4);
|
||||||
if (dst == dstEnd) break;
|
if (dst == dstEnd)
|
||||||
|
break;
|
||||||
|
|
||||||
while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--;
|
while (unbase64(*src) < 0 && src < srcEnd)
|
||||||
if (remaining <= 2 || *src == '=') break;
|
src++, remaining--;
|
||||||
|
if (remaining <= 2 || *src == '=')
|
||||||
|
break;
|
||||||
c = unbase64(*src++);
|
c = unbase64(*src++);
|
||||||
|
|
||||||
*dst++ = ((b & 0x0F) << 4) | ((c & 0x3C) >> 2);
|
*dst++ = ((b & 0x0F) << 4) | ((c & 0x3C) >> 2);
|
||||||
if (dst == dstEnd) break;
|
if (dst == dstEnd)
|
||||||
|
break;
|
||||||
|
|
||||||
while (unbase64(*src) < 0 && src < srcEnd) src++, remaining--;
|
while (unbase64(*src) < 0 && src < srcEnd)
|
||||||
if (remaining <= 3 || *src == '=') break;
|
src++, remaining--;
|
||||||
|
if (remaining <= 3 || *src == '=')
|
||||||
|
break;
|
||||||
d = unbase64(*src++);
|
d = unbase64(*src++);
|
||||||
|
|
||||||
*dst++ = ((c & 0x03) << 6) | (d & 0x3F);
|
*dst++ = ((c & 0x03) << 6) | (d & 0x3F);
|
||||||
@ -206,9 +216,12 @@ size_t base64_decode(char* buf,
|
|||||||
|
|
||||||
template <typename TypeName>
|
template <typename TypeName>
|
||||||
unsigned hex2bin(TypeName c) {
|
unsigned hex2bin(TypeName c) {
|
||||||
if (c >= '0' && c <= '9') return c - '0';
|
if (c >= '0' && c <= '9')
|
||||||
if (c >= 'A' && c <= 'F') return 10 + (c - 'A');
|
return c - '0';
|
||||||
if (c >= 'a' && c <= 'f') return 10 + (c - 'a');
|
if (c >= 'A' && c <= 'F')
|
||||||
|
return 10 + (c - 'A');
|
||||||
|
if (c >= 'a' && c <= 'f')
|
||||||
|
return 10 + (c - 'a');
|
||||||
return static_cast<unsigned>(-1);
|
return static_cast<unsigned>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +235,8 @@ size_t hex_decode(char* buf,
|
|||||||
for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) {
|
for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) {
|
||||||
unsigned a = hex2bin(src[i * 2 + 0]);
|
unsigned a = hex2bin(src[i * 2 + 0]);
|
||||||
unsigned b = hex2bin(src[i * 2 + 1]);
|
unsigned b = hex2bin(src[i * 2 + 1]);
|
||||||
if (!~a || !~b) return i;
|
if (!~a || !~b)
|
||||||
|
return i;
|
||||||
buf[i] = a * 16 + b;
|
buf[i] = a * 16 + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +359,8 @@ size_t StringBytes::Write(char* buf,
|
|||||||
|
|
||||||
|
|
||||||
bool StringBytes::IsValidString(Handle<String> string, enum encoding enc) {
|
bool StringBytes::IsValidString(Handle<String> string, enum encoding enc) {
|
||||||
if (enc == HEX && string->Length() % 2 != 0) return false;
|
if (enc == HEX && string->Length() % 2 != 0)
|
||||||
|
return false;
|
||||||
// TODO(bnoordhuis) Add BASE64 check?
|
// TODO(bnoordhuis) Add BASE64 check?
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -453,7 +468,8 @@ size_t StringBytes::Size(Handle<Value> val, enum encoding encoding) {
|
|||||||
|
|
||||||
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
||||||
for (size_t i = 0; i < len; ++i) {
|
for (size_t i = 0; i < len; ++i) {
|
||||||
if (buf[i] & 0x80) return true;
|
if (buf[i] & 0x80)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -470,7 +486,8 @@ static bool contains_non_ascii(const char* src, size_t len) {
|
|||||||
|
|
||||||
if (unaligned > 0) {
|
if (unaligned > 0) {
|
||||||
const unsigned n = bytes_per_word - unaligned;
|
const unsigned n = bytes_per_word - unaligned;
|
||||||
if (contains_non_ascii_slow(src, n)) return true;
|
if (contains_non_ascii_slow(src, n))
|
||||||
|
return true;
|
||||||
src += n;
|
src += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
}
|
}
|
||||||
@ -485,13 +502,15 @@ static bool contains_non_ascii(const char* src, size_t len) {
|
|||||||
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
||||||
|
|
||||||
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
||||||
if (srcw[i] & mask) return true;
|
if (srcw[i] & mask)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned remainder = len & align_mask;
|
const unsigned remainder = len & align_mask;
|
||||||
if (remainder > 0) {
|
if (remainder > 0) {
|
||||||
const size_t offset = len - remainder;
|
const size_t offset = len - remainder;
|
||||||
if (contains_non_ascii_slow(src + offset, remainder)) return true;
|
if (contains_non_ascii_slow(src + offset, remainder))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -400,7 +400,8 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
|
|||||||
reinterpret_cast<const sockaddr*>(&addr),
|
reinterpret_cast<const sockaddr*>(&addr),
|
||||||
AfterConnect);
|
AfterConnect);
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
if (err) delete req_wrap;
|
if (err)
|
||||||
|
delete req_wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
@ -432,7 +433,8 @@ void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
|
|||||||
reinterpret_cast<const sockaddr*>(&addr),
|
reinterpret_cast<const sockaddr*>(&addr),
|
||||||
AfterConnect);
|
AfterConnect);
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
if (err) delete req_wrap;
|
if (err)
|
||||||
|
delete req_wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
@ -449,7 +451,8 @@ Local<Object> AddressToJS(Environment* env,
|
|||||||
const sockaddr_in6 *a6;
|
const sockaddr_in6 *a6;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
if (info.IsEmpty()) info = Object::New();
|
if (info.IsEmpty())
|
||||||
|
info = Object::New();
|
||||||
|
|
||||||
switch (addr->sa_family) {
|
switch (addr->sa_family) {
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
|
@ -597,7 +597,8 @@ void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo<Value>& args) {
|
|||||||
} else {
|
} else {
|
||||||
bool reject_unauthorized = args[1]->IsTrue();
|
bool reject_unauthorized = args[1]->IsTrue();
|
||||||
verify_mode = SSL_VERIFY_PEER;
|
verify_mode = SSL_VERIFY_PEER;
|
||||||
if (reject_unauthorized) verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
|
if (reject_unauthorized)
|
||||||
|
verify_mode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Note request_cert and reject_unauthorized are ignored for clients.
|
// Note request_cert and reject_unauthorized are ignored for clients.
|
||||||
|
@ -297,7 +297,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
req_wrap->Dispatched();
|
req_wrap->Dispatched();
|
||||||
if (err) delete req_wrap;
|
if (err)
|
||||||
|
delete req_wrap;
|
||||||
|
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
}
|
}
|
||||||
@ -320,7 +321,8 @@ void UDPWrap::RecvStart(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
int err = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
|
int err = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
|
||||||
// UV_EALREADY means that the socket is already bound but that's okay
|
// UV_EALREADY means that the socket is already bound but that's okay
|
||||||
if (err == UV_EALREADY) err = 0;
|
if (err == UV_EALREADY)
|
||||||
|
err = 0;
|
||||||
args.GetReturnValue().Set(err);
|
args.GetReturnValue().Set(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ using v8::Value;
|
|||||||
void ErrName(const FunctionCallbackInfo<Value>& args) {
|
void ErrName(const FunctionCallbackInfo<Value>& args) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::HandleScope handle_scope(node_isolate);
|
||||||
int err = args[0]->Int32Value();
|
int err = args[0]->Int32Value();
|
||||||
if (err >= 0) return ThrowError("err >= 0");
|
if (err >= 0)
|
||||||
|
return ThrowError("err >= 0");
|
||||||
const char* name = uv_err_name(err);
|
const char* name = uv_err_name(err);
|
||||||
args.GetReturnValue().Set(OneByteString(node_isolate, name));
|
args.GetReturnValue().Set(OneByteString(node_isolate, name));
|
||||||
}
|
}
|
||||||
|
4
tools/cpplint.py
vendored
4
tools/cpplint.py
vendored
@ -1764,6 +1764,10 @@ def CheckSpacing(filename, clean_lines, linenum, error):
|
|||||||
error(filename, linenum, 'whitespace/operators', 4,
|
error(filename, linenum, 'whitespace/operators', 4,
|
||||||
'Missing spaces around =')
|
'Missing spaces around =')
|
||||||
|
|
||||||
|
if Match(r'^\s*(if|while) .*[^\{,)&|\\]$', line):
|
||||||
|
error(filename, linenum, 'whitespace/if-one-line', 4,
|
||||||
|
'If\'s body on the same line as if itself')
|
||||||
|
|
||||||
# It's ok not to have spaces around binary operators like + - * /, but if
|
# It's ok not to have spaces around binary operators like + - * /, but if
|
||||||
# there's too little whitespace, we get concerned. It's hard to tell,
|
# there's too little whitespace, we get concerned. It's hard to tell,
|
||||||
# though, so we punt on this one for now. TODO.
|
# though, so we punt on this one for now. TODO.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user