Fix error string buffer size validation - #1403
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds input validation to the C API function ChangesInput Validation for cuOptGetErrorString
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)cpp/src/pdlp/cuopt_c.cppcpp/src/pdlp/cuopt_c.cpp:8:10: fatal error: 'cuopt/linear_programming/cuopt_c.h' file not found ... [truncated 2200 characters] ... ClangFrontend__CTrans.CTrans_funct.instruction_insert_cxx_temporary_markers in file "src/clang/cTrans.ml", line 4866, characters 22-60 cpp/tests/linear_programming/c_api_tests/c_api_tests.cppIn file included from cpp/tests/linear_programming/c_api_tests/c_api_tests.cpp:8: ... [truncated 2200 characters] ... file "src/istd/IExn.ml" (inlined), line 18, characters 15-63 Comment |
|
There is a similar fix in #1313. Although the test case here seems better. |
|
/ok to test 4284d91 |
Signed-off-by: Rohithmatham12 <rohithmatham@gmail.com>
fb60cb2 to
92cc477
Compare
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 or invalid. Fixes NVIDIA#1311 Closes NVIDIA#1313 Closes NVIDIA#1403 Authors: - Miles Lubin (https://github.com/mlubin) Approvers: - Nicolas L. Guidotti (https://github.com/nguidotti) URL: NVIDIA#1414
Summary
error_string_sizeincuOptGetErrorStringbefore callingsnprintf.Fixes #1311.
Testing
/opt/homebrew/opt/llvm/bin/clang-format -i cpp/src/pdlp/cuopt_c.cpp cpp/include/cuopt/linear_programming/cuopt_c.h cpp/tests/linear_programming/c_api_tests/c_api_tests.cppgit diff --check