buffer: guard against integer overflow

This commit is contained in:
Ben Noordhuis 2013-05-26 21:42:23 +02:00
parent 36ebff0470
commit c188a75103

View File

@ -404,7 +404,7 @@ Handle<Value> ReadFloatGeneric(const Arguments& args) {
return ThrowTypeError("offset is not uint");
size_t len = static_cast<size_t>(
args.This()->GetIndexedPropertiesExternalArrayDataLength());
if (offset + sizeof(T) > len)
if (offset + sizeof(T) > len || offset + sizeof(T) < offset)
return ThrowRangeError("Trying to read beyond buffer length");
}