From: Andreas Steffen Date: Sat, 31 May 2014 18:33:19 +0000 (+0200) Subject: Allow large lines output by swid_generator to be processed X-Git-Tag: 5.2.0dr5~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a6d2f2bceaae0617c6994929e1b35b14169be9a;p=thirdparty%2Fstrongswan.git Allow large lines output by swid_generator to be processed --- diff --git a/src/libpts/swid/swid_inventory.c b/src/libpts/swid/swid_inventory.c index 4b1f7fb20f..86f47a3573 100644 --- a/src/libpts/swid/swid_inventory.c +++ b/src/libpts/swid/swid_inventory.c @@ -60,11 +60,13 @@ static status_t read_swid_tags(private_swid_inventory_t *this, FILE *file) swid_tag_t *tag; bio_writer_t *writer; chunk_t tag_encoding, tag_file_path = chunk_empty; - bool more_tags = TRUE, end_of_tag; - char line[131072]; + bool more_tags = TRUE, last_newline, end_of_tag; + char line[8192]; + size_t len; while (more_tags) { + last_newline = TRUE; end_of_tag = FALSE; writer = bio_writer_create(512); do @@ -75,14 +77,17 @@ static status_t read_swid_tags(private_swid_inventory_t *this, FILE *file) end_of_tag = TRUE; break; } - if (line[0] == '\n') + len = strlen(line); + + if (last_newline && line[0] == '\n') { end_of_tag = TRUE; break; } else { - writer->write_data(writer, chunk_from_str(line)); + last_newline = (line[len-1] == '\n'); + writer->write_data(writer, chunk_create(line, len)); } } while (!end_of_tag); @@ -155,6 +160,8 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator, FILE *file; char command[BUF_LEN]; char entity_name[] = "strongSwan Project"; + char doc_separator[] = "'\n\n'"; + status_t status = SUCCESS; if (targets->get_count(targets) == 0) @@ -163,7 +170,8 @@ static status_t generate_tags(private_swid_inventory_t *this, char *generator, if (this->full_tags) { snprintf(command, BUF_LEN, "%s swid --entity-name \"%s\" " - "--doc-separator $'\n\n'%s%s", generator, entity_name, + "--doc-separator %s%s%s", + generator, entity_name, doc_separator, pretty ? " --pretty" : "", full ? " --full" : ""); } else