+55
-17
lines changedFilter options
+55
-17
lines changed Original file line number Diff line number Diff line change
@@ -708,7 +708,10 @@ CipherBase::UpdateResult CipherBase::Update(
708
708
*out = ArrayBuffer::NewBackingStore(env()->isolate(), 0);
709
709
} else if (static_cast<size_t>(buf_len) != (*out)->ByteLength()) {
710
710
std::unique_ptr<BackingStore> old_out = std::move(*out);
711
-
*out = ArrayBuffer::NewBackingStore(env()->isolate(), buf_len);
711
+
*out = ArrayBuffer::NewBackingStore(
712
+
env()->isolate(),
713
+
buf_len,
714
+
BackingStoreInitializationMode::kUninitialized);
712
715
memcpy((*out)->Data(), old_out->Data(), buf_len);
713
716
}
714
717
@@ -804,7 +807,10 @@ bool CipherBase::Final(std::unique_ptr<BackingStore>* out) {
804
807
*out = ArrayBuffer::NewBackingStore(env()->isolate(), 0);
805
808
} else if (static_cast<size_t>(out_len) != (*out)->ByteLength()) {
806
809
std::unique_ptr<BackingStore> old_out = std::move(*out);
807
-
*out = ArrayBuffer::NewBackingStore(env()->isolate(), out_len);
810
+
*out = ArrayBuffer::NewBackingStore(
811
+
env()->isolate(),
812
+
out_len,
813
+
BackingStoreInitializationMode::kUninitialized);
808
814
memcpy((*out)->Data(), old_out->Data(), out_len);
809
815
}
810
816
@@ -880,7 +886,10 @@ bool PublicKeyCipher::Cipher(
880
886
if (buf.size() == 0) {
881
887
*out = ArrayBuffer::NewBackingStore(env->isolate(), 0);
882
888
} else {
883
-
*out = ArrayBuffer::NewBackingStore(env->isolate(), buf.size());
889
+
*out = ArrayBuffer::NewBackingStore(
890
+
env->isolate(),
891
+
buf.size(),
892
+
BackingStoreInitializationMode::kUninitialized);
884
893
memcpy((*out)->Data(), buf.get(), buf.size());
885
894
}
886
895
Original file line number Diff line number Diff line change
@@ -99,7 +99,10 @@ std::unique_ptr<BackingStore> Node_SignFinal(Environment* env,
99
99
[[likely]] {
100
100
CHECK_LE(sig_buf.len, sig->ByteLength());
101
101
if (sig_buf.len < sig->ByteLength()) {
102
-
auto new_sig = ArrayBuffer::NewBackingStore(env->isolate(), sig_buf.len);
102
+
auto new_sig = ArrayBuffer::NewBackingStore(
103
+
env->isolate(),
104
+
sig_buf.len,
105
+
BackingStoreInitializationMode::kUninitialized);
103
106
if (sig_buf.len > 0) [[likely]] {
104
107
memcpy(new_sig->Data(), sig->Data(), sig_buf.len);
105
108
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ using v8::Array;
21
21
using v8::ArrayBuffer;
22
22
using v8::ArrayBufferView;
23
23
using v8::BackingStore;
24
+
using v8::BackingStoreInitializationMode;
24
25
using v8::Context;
25
26
using v8::Function;
26
27
using v8::FunctionCallbackInfo;
@@ -82,8 +83,8 @@ void Concat(const FunctionCallbackInfo<Value>& args) {
82
83
}
83
84
}
84
85
85
-
std::shared_ptr<BackingStore> store =
86
-
ArrayBuffer::NewBackingStore(env->isolate(), total);
86
+
std::shared_ptr<BackingStore> store = ArrayBuffer::NewBackingStore(
87
+
env->isolate(), total, BackingStoreInitializationMode::kUninitialized);
87
88
uint8_t* ptr = static_cast<uint8_t*>(store->Data());
88
89
for (size_t n = 0; n < views.size(); n++) {
89
90
uint8_t* from =
@@ -210,8 +211,8 @@ void Blob::New(const FunctionCallbackInfo<Value>& args) {
210
211
}
211
212
212
213
// If the ArrayBuffer is not detachable, we will copy from it instead.
213
-
std::shared_ptr<BackingStore> store =
214
-
ArrayBuffer::NewBackingStore(isolate, byte_length);
214
+
std::shared_ptr<BackingStore> store = ArrayBuffer::NewBackingStore(
215
+
isolate, byte_length, BackingStoreInitializationMode::kUninitialized);
215
216
uint8_t* ptr = static_cast<uint8_t*>(buf->Data()) + byte_offset;
216
217
std::copy(ptr, ptr + byte_length, static_cast<uint8_t*>(store->Data()));
217
218
return DataQueue::CreateInMemoryEntryFromBackingStore(
@@ -375,8 +376,10 @@ void Blob::Reader::Pull(const FunctionCallbackInfo<Value>& args) {
375
376
size_t total = 0;
376
377
for (size_t n = 0; n < count; n++) total += vecs[n].len;
377
378
378
-
std::shared_ptr<BackingStore> store =
379
-
ArrayBuffer::NewBackingStore(env->isolate(), total);
379
+
std::shared_ptr<BackingStore> store = ArrayBuffer::NewBackingStore(
380
+
env->isolate(),
381
+
total,
382
+
BackingStoreInitializationMode::kUninitialized);
380
383
auto ptr = static_cast<uint8_t*>(store->Data());
381
384
for (size_t n = 0; n < count; n++) {
382
385
std::copy(vecs[n].base, vecs[n].base + vecs[n].len, ptr);
Original file line number Diff line number Diff line change
@@ -329,7 +329,8 @@ MaybeLocal<Object> New(Isolate* isolate,
329
329
if (actual > 0) [[likely]] {
330
330
if (actual < length) {
331
331
std::unique_ptr<BackingStore> old_store = std::move(store);
332
-
store = ArrayBuffer::NewBackingStore(isolate, actual);
332
+
store = ArrayBuffer::NewBackingStore(
333
+
isolate, actual, BackingStoreInitializationMode::kUninitialized);
333
334
memcpy(store->Data(), old_store->Data(), actual);
334
335
}
335
336
Local<ArrayBuffer> buf = ArrayBuffer::New(isolate, std::move(store));
@@ -416,7 +417,7 @@ MaybeLocal<Object> Copy(Environment* env, const char* data, size_t length) {
416
417
417
418
CHECK(bs);
418
419
419
-
memcpy(bs->Data(), data, length);
420
+
if (length > 0) memcpy(bs->Data(), data, length);
420
421
421
422
Local<ArrayBuffer> ab = ArrayBuffer::New(isolate, std::move(bs));
422
423
@@ -506,6 +507,17 @@ MaybeLocal<Object> New(Environment* env,
506
507
}
507
508
}
508
509
510
+
#if defined(V8_ENABLE_SANDBOX)
511
+
// When v8 sandbox is enabled, external backing stores are not supported
512
+
// since all arraybuffer allocations are expected to be done by the isolate.
513
+
// Since this violates the contract of this function, let's free the data and
514
+
// throw an error.
515
+
free(data);
516
+
THROW_ERR_OPERATION_FAILED(
517
+
env->isolate(),
518
+
"Wrapping external data is not supported when the v8 sandbox is enabled");
519
+
return MaybeLocal<Object>();
520
+
#else
509
521
EscapableHandleScope handle_scope(env->isolate());
510
522
511
523
auto free_callback = [](void* data, size_t length, void* deleter_data) {
@@ -520,6 +532,7 @@ MaybeLocal<Object> New(Environment* env,
520
532
if (Buffer::New(env, ab, 0, length).ToLocal(&obj))
521
533
return handle_scope.Escape(obj);
522
534
return Local<Object>();
535
+
#endif
523
536
}
524
537
525
538
namespace {
Original file line number Diff line number Diff line change
@@ -2104,7 +2104,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
2104
2104
[[likely]] {
2105
2105
// Shrink to the actual amount of used data.
2106
2106
std::unique_ptr<BackingStore> old_bs = std::move(bs);
2107
-
bs = ArrayBuffer::NewBackingStore(env()->isolate(), nread);
2107
+
bs = ArrayBuffer::NewBackingStore(
2108
+
env()->isolate(),
2109
+
nread,
2110
+
BackingStoreInitializationMode::kUninitialized);
2108
2111
memcpy(bs->Data(), old_bs->Data(), nread);
2109
2112
} else {
2110
2113
// This is a very unlikely case, and should only happen if the ReadStart()
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ namespace sqlite {
19
19
20
20
using v8::Array;
21
21
using v8::ArrayBuffer;
22
+
using v8::BackingStoreInitializationMode;
22
23
using v8::BigInt;
23
24
using v8::Boolean;
24
25
using v8::ConstructorBehavior;
@@ -103,7 +104,8 @@ using v8::Value;
103
104
static_cast<size_t>(sqlite3_##from##_bytes(__VA_ARGS__)); \
104
105
auto data = reinterpret_cast<const uint8_t*>( \
105
106
sqlite3_##from##_blob(__VA_ARGS__)); \
106
-
auto store = ArrayBuffer::NewBackingStore((isolate), size); \
107
+
auto store = ArrayBuffer::NewBackingStore( \
108
+
(isolate), size, BackingStoreInitializationMode::kUninitialized); \
107
109
memcpy(store->Data(), data, size); \
108
110
auto ab = ArrayBuffer::New((isolate), std::move(store)); \
109
111
(result) = Uint8Array::New(ab, 0, size); \
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ namespace node {
18
18
using v8::Array;
19
19
using v8::ArrayBuffer;
20
20
using v8::ArrayBufferView;
21
+
using v8::BackingStoreInitializationMode;
21
22
using v8::BigInt;
22
23
using v8::FunctionCallbackInfo;
23
24
using v8::FunctionTemplate;
@@ -1198,7 +1199,8 @@ void Stream::ReceiveData(const uint8_t* data,
1198
1199
1199
1200
STAT_INCREMENT_N(Stats, bytes_received, len);
1200
1201
STAT_RECORD_TIMESTAMP(Stats, received_at);
1201
-
auto backing = ArrayBuffer::NewBackingStore(env()->isolate(), len);
1202
+
auto backing = ArrayBuffer::NewBackingStore(
1203
+
env()->isolate(), len, BackingStoreInitializationMode::kUninitialized);
1202
1204
memcpy(backing->Data(), data, len);
1203
1205
inbound_->append(DataQueue::CreateInMemoryEntryFromBackingStore(
1204
1206
std::move(backing), 0, len));
Original file line number Diff line number Diff line change
@@ -708,7 +708,8 @@ void EmitToJSStreamListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
708
708
CHECK_LE(static_cast<size_t>(nread), bs->ByteLength());
709
709
if (static_cast<size_t>(nread) != bs->ByteLength()) {
710
710
std::unique_ptr<BackingStore> old_bs = std::move(bs);
711
-
bs = ArrayBuffer::NewBackingStore(isolate, nread);
711
+
bs = ArrayBuffer::NewBackingStore(
712
+
isolate, nread, BackingStoreInitializationMode::kUninitialized);
712
713
memcpy(bs->Data(), old_bs->Data(), nread);
713
714
}
714
715
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ using errors::TryCatchScope;
35
35
using v8::Array;
36
36
using v8::ArrayBuffer;
37
37
using v8::BackingStore;
38
+
using v8::BackingStoreInitializationMode;
38
39
using v8::Boolean;
39
40
using v8::Context;
40
41
using v8::DontDelete;
@@ -759,7 +760,8 @@ void UDPWrap::OnRecv(ssize_t nread,
759
760
} else if (static_cast<size_t>(nread) != bs->ByteLength()) {
760
761
CHECK_LE(static_cast<size_t>(nread), bs->ByteLength());
761
762
std::unique_ptr<BackingStore> old_bs = std::move(bs);
762
-
bs = ArrayBuffer::NewBackingStore(isolate, nread);
763
+
bs = ArrayBuffer::NewBackingStore(
764
+
isolate, nread, BackingStoreInitializationMode::kUninitialized);
763
765
memcpy(bs->Data(), old_bs->Data(), nread);
764
766
}
765
767
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4