From ef1503b769c59b6b163230ecb9d22d036153ea14 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 26 Jan 2017 13:10:52 -0600 Subject: [PATCH] libpkgconf: strip trailing whitespace --- libpkgconf/pkg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index a574d64..ccf10f6 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -266,7 +266,8 @@ pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, if (!isalpha((unsigned int)*key) && !isdigit((unsigned int)*p)) continue; - while (*p && isspace((unsigned int)*p)) { + while (*p && isspace((unsigned int)*p)) + { /* set to null to avoid trailing spaces in key */ *p = '\0'; p++; @@ -280,6 +281,12 @@ pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, p++; value = p; + p = value + (strlen(value) - 1); + while (*p && isspace((unsigned int) *p) && p > value) + { + *p = '\0'; + p--; + } switch (op) {