Skip to content

Commit 08383be

Browse files
committed
Removed a check to enforce each string value of an array to be of size less than maxSize to be consistent with scalar implementation. If an empty array is provided, report error and bail out.
1 parent 3c5f3cd commit 08383be

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/njs/src/njsConnection.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -715,15 +715,22 @@ void Connection::GetBindUnit (Local<Value> val, Bind* bind,
715715
* For OUT bind, we can NOT determine the out value as ARRAY and so
716716
* no validation done here.
717717
*/
718-
if ( dir == BIND_INOUT && element->IsArray () )
718+
if ( element->IsArray () )
719719
{
720720
Local<Array>arr = Local<Array>::Cast (element);
721721

722-
if ( arr->Length() > bind->maxArraySize )
722+
if ( dir == BIND_INOUT && ( arr->Length() > bind->maxArraySize ) )
723723
{
724724
executeBaton->error = NJSMessages::getErrorMsg ( errInvalidArraySize );
725725
goto exitGetBindUnit;
726726
}
727+
728+
/* For IN bind, empty array is not allowed */
729+
if ( ( dir == BIND_IN || dir == BIND_INOUT ) && ( arr->Length () == 0 ) )
730+
{
731+
executeBaton->error = NJSMessages::getErrorMsg ( errEmptyArray ) ;
732+
goto exitGetBindUnit;
733+
}
727734
}
728735

729736
/* REFCURSOR(s) are supported only as OUT Binds now */
@@ -1128,15 +1135,6 @@ void Connection::GetInBindParamsArray(Local<Array> va8vals, Bind *bind,
11281135
{
11291136
arrayElementSize = stringLength;
11301137
}
1131-
1132-
// Check if we have a string with a size larger then the specified
1133-
// maxSize (there is actually a default for maxSize if not specified)
1134-
if (stringLength > static_cast<size_t>(bind->maxSize))
1135-
{
1136-
executeBaton->error = NJSMessages::getErrorMsg(
1137-
errInvalidValueArrayBind);
1138-
goto exitGetInBindParamsArray;
1139-
}
11401138
}
11411139
break;
11421140

src/njs/src/njsMessages.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ static const char *errMsg[] =
7676
"NJS-036: given array is of size greater than maxArraySize",
7777
"NJS-037: incompatible type of value provided",
7878
"NJS-038: maxArraySize value should be greater than 0",
79-
80-
79+
"NJS-039: empty array is not allowed for IN bind",
8180
};
8281

8382
string NJSMessages::getErrorMsg ( NJSErrorType err, ... )

src/njs/src/njsMessages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ typedef enum
7272
errInvalidArraySize,
7373
errIncompatibleTypeArrayBind,
7474
errInvalidValueArrayBind,
75+
errEmptyArray,
7576

7677

7778
// New ones should be added here

0 commit comments

Comments
 (0)