From ae179dcbb64f8797235f20521ac7dfcf3ce65ce4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 10 Feb 2017 10:28:09 +0100 Subject: [PATCH] libopkg: discard empty control file fields If the resulting string is empty after whitespace trimming, free it and store NULL instead of an empty string buffer. Signed-off-by: Jo-Philipp Wich --- libopkg/parse_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libopkg/parse_util.c b/libopkg/parse_util.c index fbecba6..2aef7a9 100644 --- a/libopkg/parse_util.c +++ b/libopkg/parse_util.c @@ -35,7 +35,12 @@ is_field(const char *type, const char *line) char * parse_simple(const char *type, const char *line) { - return trim_xstrdup(line + strlen(type) + 1); + char *field = trim_xstrdup(line + strlen(type) + 1); + if (strlen(field) == 0) { + free(field); + return NULL; + } + return field; } /* -- 2.25.1