From 0fc2fc2b162fe5f2d9c180bdcb226da1770538ac Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 22 Jan 2026 14:48:40 -0800 Subject: [PATCH] Revert "fix: Improve bounds checking on integer conversions (#8612)" This reverts commit 3c205db3076c7135897b76346ec9a0b2b8eb78d8. --- src/http_server.cc | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/http_server.cc b/src/http_server.cc index b0e5ef7902..86707899f3 100644 --- a/src/http_server.cc +++ b/src/http_server.cc @@ -603,30 +603,21 @@ ReadDataFromJsonHelper( break; } case TRITONSERVER_TYPE_BYTES: { - const char* cstr{nullptr}; - size_t len{0}; + const char* cstr; + size_t len = 0; RETURN_IF_ERR(tensor_data.AsString(&cstr, &len)); - if (len > INT64_MAX) { - return TRITONSERVER_ErrorNew( - TRITONSERVER_ERROR_INTERNAL, - "Unable to parse 'data' field: string length exceeds size" - " limitation"); - } // Quick sanity check to ensure we don't write beyond `expected_cnt`. - int64_t tmp_cnt = static_cast(*counter) + - static_cast(len) + - static_cast(sizeof(uint32_t)); - if (tmp_cnt < 0 || tmp_cnt > expected_cnt) { + int32_t actual_cnt = *counter + len + sizeof(uint32_t); + if (actual_cnt < 0) { return TRITONSERVER_ErrorNew( TRITONSERVER_ERROR_INTERNAL, - "Shape does not match true shape of 'data' field"); + "Unable to parse 'data' field: string length is negative"); } - if (tmp_cnt > INT32_MAX) { + if (static_cast(actual_cnt) > expected_cnt) { return TRITONSERVER_ErrorNew( TRITONSERVER_ERROR_INTERNAL, - "Unable to parse 'data' field: string length exceeds INT32_MAX"); + "Shape does not match true shape of 'data' field"); } - int32_t actual_cnt = static_cast(tmp_cnt); memcpy( base + *counter, reinterpret_cast(&len), sizeof(uint32_t)); std::copy(cstr, cstr + len, base + *counter + sizeof(uint32_t));