Validate source/destination indices correctly in nodejs support (#5595)

* validate source/destination indices correctly

Co-authored-by: Denis Chapligin <denis.chaplygin@wolt.com>
Co-authored-by: Daniel Patterson <danpat@danpat.net>
This commit is contained in:
Karen Shea
2021-01-28 15:02:01 +01:00
committed by GitHub
parent 960269f95a
commit a613375460
4 changed files with 22 additions and 8 deletions
+4 -5
View File
@@ -1210,10 +1210,9 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (source->IsUint32())
{
size_t source_value = Nan::To<unsigned>(source).FromJust();
if (source_value > params->coordinates.size())
if (source_value >= params->coordinates.size())
{
Nan::ThrowError(
"Source indices must be less than or equal to the number of coordinates");
Nan::ThrowError("Source indices must be less than the number of coordinates");
return table_parameters_ptr();
}
@@ -1250,9 +1249,9 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (destination->IsUint32())
{
size_t destination_value = Nan::To<unsigned>(destination).FromJust();
if (destination_value > params->coordinates.size())
if (destination_value >= params->coordinates.size())
{
Nan::ThrowError("Destination indices must be less than or equal to the number "
Nan::ThrowError("Destination indices must be less than the number "
"of coordinates");
return table_parameters_ptr();
}