]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
opencl : fix possible buffer overflow in dump_tensor (#14490)
authorzhouwg <redacted>
Wed, 2 Jul 2025 12:38:10 +0000 (20:38 +0800)
committerGitHub <redacted>
Wed, 2 Jul 2025 12:38:10 +0000 (14:38 +0200)
ggml/src/ggml-opencl/ggml-opencl.cpp

index f747f756816facaeb137892da9aabf14c6343d7c..71829c05a5bf626e85fc72848c7fed8534aab5aa 100644 (file)
@@ -3199,7 +3199,7 @@ static void dump_tensor(ggml_backend_t backend, const struct ggml_tensor * tenso
 
     // Open file and dump.
     char fname[512];
-    sprintf(fname, "./tensor-dumps/%s.txt", tensor->name);
+    snprintf(fname, sizeof(fname), "./tensor-dumps/%s.txt", tensor->name);
     FILE * f = fopen(fname, "w");
     if (!f) {
         printf("Failed to open %s\n", fname);