]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
rpc : avoid uninitialized memory in serialize_tensor (#13210)
authorJustin Santa Barbara <redacted>
Thu, 1 May 2025 21:32:11 +0000 (17:32 -0400)
committerGitHub <redacted>
Thu, 1 May 2025 21:32:11 +0000 (23:32 +0200)
Zero out the name and padding buffers.

ggml/src/ggml-rpc/ggml-rpc.cpp

index 140a775f9806f3b5ccf6c25862c0e41b763fbcbc..e662cc6eb3f48133567bb0a013205214c0f23e65 100644 (file)
@@ -518,6 +518,11 @@ static rpc_tensor serialize_tensor(const ggml_tensor * tensor) {
     result.view_src = reinterpret_cast<uint64_t>(tensor->view_src);
     result.view_offs = tensor->view_offs;
     result.data = reinterpret_cast<uint64_t>(tensor->data);
+
+    // Avoid sending uninitialized data over the wire
+    memset(result.name, 0, sizeof(result.name));
+    memset(result.padding, 0, sizeof(result.padding));
+
     snprintf(result.name, GGML_MAX_NAME, "%s", tensor->name);
     return result;
 }