From ceafcbe76843948bcd04a1638441568294969a8c Mon Sep 17 00:00:00 2001 From: Jaeyun Jung Date: Tue, 10 Mar 2026 12:15:21 +0900 Subject: [PATCH] [C-Api] check index Check max limit of tensors when parsing json string. Signed-off-by: Jaeyun Jung --- c/src/ml-api-service.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c/src/ml-api-service.c b/c/src/ml-api-service.c index c3e281ba..907ec230 100644 --- a/c/src/ml-api-service.c +++ b/c/src/ml-api-service.c @@ -237,6 +237,12 @@ _ml_service_conf_parse_tensors_info (JsonNode * info_node, if (JSON_NODE_HOLDS_ARRAY (info_node)) { array = json_node_get_array (info_node); info.num_tensors = json_array_get_length (array); + + if (info.num_tensors > NNS_TENSOR_SIZE_LIMIT) { + _ml_error_report_return (ML_ERROR_INVALID_PARAMETER, + "The array length of json for tensor information (%u) exceeds the max limit.", + info.num_tensors); + } } for (i = 0; i < info.num_tensors; i++) {