quantize: fix imatrix GGUF filepath metadata leak (#32000)

This commit is contained in:
JamieBordoni authored and GitHub committed 2026-11-11 19:13:28 +08:00
1 parent 7f24aacde3
commit 71a6a114bc
1 file changed
+4 -2
+4 -2
View File
@@ -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));
}