From 8781dd3e7bc1e3f2762b4e78057d82296cff8627 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Tue, 24 Nov 2020 11:20:35 +0100 Subject: [PATCH] zkey-ekmfweb: Fix selection of key properties to set or remove MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When some of the key properties are skipped due to null_values_only being true or false, then the resulting EKMF tag list might be built incorrectly. Signed-off-by: Ingo Franzki Signed-off-by: Jan Höppner --- zkey/ekmfweb/zkey-ekmfweb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zkey/ekmfweb/zkey-ekmfweb.c b/zkey/ekmfweb/zkey-ekmfweb.c index a8ca3c28..761341a7 100644 --- a/zkey/ekmfweb/zkey-ekmfweb.c +++ b/zkey/ekmfweb/zkey-ekmfweb.c @@ -4566,22 +4566,23 @@ static int _properties_to_ekmf_tags(struct plugin_handle *UNUSED(ph), struct ekmf_tag_list *ekmf_tag_list, bool null_values_only) { - size_t i; + size_t i, k; ekmf_tag_list->num_tags = 0; ekmf_tag_list->tags = util_malloc( sizeof(struct ekmf_tag) * num_properties); - for (i = 0; i < num_properties; i++) { + for (i = 0, k = 0; i < num_properties; i++) { if (!null_values_only && properties[i].value == NULL) continue; if (null_values_only && properties[i].value != NULL) continue; - ekmf_tag_list->tags[i].name = util_strdup(properties[i].name); - ekmf_tag_list->tags[i].value = properties[i].value != NULL ? + ekmf_tag_list->tags[k].name = util_strdup(properties[i].name); + ekmf_tag_list->tags[k].value = properties[i].value != NULL ? util_strdup(properties[i].value) : NULL; ekmf_tag_list->num_tags++; + k++; } return 0;