From 71a6a114bca2f0901cb88da36eca8d4720e22ec5 Mon Sep 17 00:00:00 2001 From: JamieBordoni Date: Wed, 11 Nov 2026 11:13:28 +0000 Subject: [PATCH] quantize: fix imatrix GGUF filepath metadata leak (#32000) --- tools/quantize/quantize.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/quantize/quantize.cpp b/tools/quantize/quantize.cpp index 38950036c..0debcfdda 100644 --- a/tools/quantize/quantize.cpp +++ b/tools/quantize/quantize.cpp @@ -510,7 +510,8 @@ int llama_quantize(int argc, char ** argv) { llama_model_kv_override kvo; std::strcpy(kvo.key, LLM_KV_QUANTIZE_IMATRIX_FILE); kvo.tag = LLAMA_KV_OVERRIDE_TYPE_STR; - strncpy(kvo.val_str, imatrix_file.c_str(), 127); + const std::string fname_imatrix = std::filesystem::path(imatrix_file).filename().string(); + strncpy(kvo.val_str, fname_imatrix.c_str(), 127); kvo.val_str[127] = '\0'; kv_overrides.emplace_back(std::move(kvo)); } @@ -519,7 +520,8 @@ int llama_quantize(int argc, char ** argv) { // TODO: list multiple datasets when there are more than one std::strcpy(kvo.key, LLM_KV_QUANTIZE_IMATRIX_DATASET); kvo.tag = LLAMA_KV_OVERRIDE_TYPE_STR; - strncpy(kvo.val_str, imatrix_datasets[0].c_str(), 127); + const std::string fname_dataset = std::filesystem::path(imatrix_datasets[0]).filename().string(); + strncpy(kvo.val_str, fname_dataset.c_str(), 127); kvo.val_str[127] = '\0'; kv_overrides.emplace_back(std::move(kvo)); }