-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
We can get integer overflow easily with our current uses of zone->Allocate(). We should consider moving to a calloc-style, size+count interface which checks explicitly for integer overflow.
This causes potential overflow in some of the following places:
runtime/lib/string.cc:
DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
[...]
const Array& a = Array::CheckedHandle(arguments->At(0));
[...]
intptr_t len = a.Length();
[...]
uint32_t* temp = reinterpret_cast<uint32_t*>(
zone->Allocate(len * sizeof(uint32_t))); // NOLINT ← Here!!!! len is controllable from the script
lib/regexp_jsc.cc (x2)
intptr_t size = str.Length() * sizeof(uint16_t);
Zone* zone = Isolate::Current()->current_zone();
uint16_t* two_byte_str = reinterpret_cast<uint16_t*>(zone->Allocate(size));
int offsets_length = (num_bracket_expressions + 1) * kJscreMultiple;
int* offsets = NULL;
int offsets_array_size = offsets_length * sizeof(offsets[0]);
offsets = reinterpret_cast<int*>(zone->Allocate(offsets_array_size));