From 3b71a31bd35d80d073ceb90b5f61bfa6a8a0dd16 Mon Sep 17 00:00:00 2001 From: tomaioo Date: Mon, 3 Aug 2026 23:56:33 -0700 Subject: [PATCH] fix(security): 2 improvements across 1 files - Security: Format String Vulnerability in CHECK Macro - Security: Potential Buffer Overflow in CUDA_CHECK Macro Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com> --- csrc/kda/sm90/utils/common.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csrc/kda/sm90/utils/common.hpp b/csrc/kda/sm90/utils/common.hpp index a307de68..e9d7f0e8 100644 --- a/csrc/kda/sm90/utils/common.hpp +++ b/csrc/kda/sm90/utils/common.hpp @@ -42,7 +42,7 @@ do { \ if (!(expr)) { \ std::string buffer(1024, '\0'); \ - sprintf(buffer.data(), "Failed to check %s, %s at %s:%d\n", ##expr, msg __FILE__, __LINE__); \ + snprintf(buffer.data(), buffer.size(), "Failed to check %s, %s at %s:%d\n", #expr, msg, __FILE__, __LINE__); \ throw std::runtime_error(buffer.c_str()); \ } \ } while (0) @@ -52,8 +52,8 @@ cudaError_t err = (expr); \ if (err != cudaSuccess) { \ std::string buffer(1024, '\0'); \ - sprintf( \ - buffer.data(), "CUDA Error: %s, Code: %d at %s:%d\n", cudaGetErrorName(err), err, __FILE__, __LINE__); \ + snprintf( \ + buffer.data(), buffer.size(), "CUDA Error: %s, Code: %d at %s:%d\n", cudaGetErrorName(err), err, __FILE__, __LINE__); \ throw std::runtime_error(buffer.c_str()); \ } \ } while (0)