From: Andreas Steffen Date: Tue, 15 Apr 2014 06:55:11 +0000 (+0200) Subject: Handle tag separators X-Git-Tag: 5.2.0dr1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa6c5f3506e326c15fd1a9a23e030e9294fe3ace;p=thirdparty%2Fstrongswan.git Handle tag separators --- diff --git a/src/libpts/swid/swid_inventory.c b/src/libpts/swid/swid_inventory.c index 062bf4ec5d..9d49324582 100644 --- a/src/libpts/swid/swid_inventory.c +++ b/src/libpts/swid/swid_inventory.c @@ -63,10 +63,11 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator, status_t status = SUCCESS; /* Assemble the SWID generator command */ - snprintf(command, sizeof(command), "%s %s%s%s\n", generator, - (this->full_tags) ? "swid" : "software-id", - (this->full_tags && pretty) ? " --pretty" : "", - (this->full_tags && full) ? " --full" : ""); + snprintf(command, sizeof(command), "%s %s%s%s%s\n", generator, + (this->full_tags) ? "swid" : "software-id", + (this->full_tags && pretty) ? " --pretty" : "", + (this->full_tags && !pretty) ? " --doc-separator $'\n\n'" : "", + (this->full_tags && full) ? " --full" : ""); /* Open a pipe stream for reading the output of the dpkg-query commmand */ file = popen(command, "r"); @@ -108,16 +109,18 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator, tag_encoding = writer->get_buf(writer); - /* remove trailing newline if present */ - if (tag_encoding.len > 0 && - tag_encoding.ptr[tag_encoding.len - 1] == '\n') + if (tag_encoding.len > 1) { - tag_encoding.len--; - } - DBG2(DBG_IMC, " %.*s", tag_encoding.len, tag_encoding.ptr); + /* remove trailing newline if present */ + if (tag_encoding.ptr[tag_encoding.len - 1] == '\n') + { + tag_encoding.len--; + } + DBG2(DBG_IMC, " %.*s", tag_encoding.len, tag_encoding.ptr); - tag = swid_tag_create(tag_encoding, tag_file_path); - this->list->insert_last(this->list, tag); + tag = swid_tag_create(tag_encoding, tag_file_path); + this->list->insert_last(this->list, tag); + } writer->destroy(writer); } } diff --git a/testing/tests/tnc/tnccs-20-pdp-eap/hosts/dave/etc/strongswan.conf b/testing/tests/tnc/tnccs-20-pdp-eap/hosts/dave/etc/strongswan.conf index e9dfc8d9fb..aefbfde95b 100644 --- a/testing/tests/tnc/tnccs-20-pdp-eap/hosts/dave/etc/strongswan.conf +++ b/testing/tests/tnc/tnccs-20-pdp-eap/hosts/dave/etc/strongswan.conf @@ -24,7 +24,7 @@ libimcv { push_info = no } imc-swid { - swid_pretty = yes + swid_pretty = no } } }