From 1be2a7e85828e26b7e9fbaabe8505ee74af64d99 Mon Sep 17 00:00:00 2001 From: Miles Lubin Date: Tue, 9 Jun 2026 21:22:43 -0400 Subject: [PATCH] check for valid size in cuOptGetErrorString snprintf takes a size_t, so we should be sure to not pass a negative size to it. A zero size is technically correct and not dangerous. --- cpp/src/pdlp/cuopt_c.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/src/pdlp/cuopt_c.cpp b/cpp/src/pdlp/cuopt_c.cpp index fa27e4504b..bf3f6f7433 100644 --- a/cpp/src/pdlp/cuopt_c.cpp +++ b/cpp/src/pdlp/cuopt_c.cpp @@ -1174,6 +1174,7 @@ cuopt_int_t cuOptGetErrorString(cuOptSolution solution, { if (solution == nullptr) { return CUOPT_INVALID_ARGUMENT; } if (error_string_ptr == nullptr) { return CUOPT_INVALID_ARGUMENT; } + if (error_string_size < 0) { return CUOPT_INVALID_ARGUMENT; } solution_and_stream_view_t* solution_and_stream_view = static_cast(solution); std::string error_string = solution_and_stream_view->get_solution()->get_error_status().what();