File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -603,17 +603,19 @@ ReadDataFromJsonHelper(
603603 break ;
604604 }
605605 case TRITONSERVER_TYPE_BYTES: {
606- const char * cstr;
607- size_t len = 0 ;
606+ const char * cstr{ nullptr } ;
607+ size_t len{ 0 } ;
608608 RETURN_IF_ERR (tensor_data.AsString (&cstr, &len));
609- // Quick sanity check to ensure we don't write beyond `expected_cnt`.
610- int32_t actual_cnt = *counter + len + sizeof (uint32_t );
611- if (actual_cnt < 0 ) {
609+ if (len > INT64_MAX) {
612610 return TRITONSERVER_ErrorNew (
613611 TRITONSERVER_ERROR_INTERNAL,
614- " Unable to parse 'data' field: string length is negative " );
612+ " Tensor size is too large to be processed " );
615613 }
616- if (static_cast <int64_t >(actual_cnt) > expected_cnt) {
614+ // Quick sanity check to ensure we don't write beyond `expected_cnt`.
615+ int64_t actual_cnt = static_cast <int64_t >(*counter) +
616+ static_cast <int64_t >(len) +
617+ static_cast <int64_t >(sizeof (uint32_t ));
618+ if (actual_cnt < 0 || actual_cnt > expected_cnt) {
617619 return TRITONSERVER_ErrorNew (
618620 TRITONSERVER_ERROR_INTERNAL,
619621 " Shape does not match true shape of 'data' field" );
You can’t perform that action at this time.
0 commit comments