aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2022-06-14 08:35:35 +0200
committerFabian Groffen <grobian@gentoo.org>2022-06-14 08:35:35 +0200
commit2100df5c171029d6c347650fdaf098b67df0f059 (patch)
tree36e4432a495bbccf364fb284205d6f156ed63bee
parentbuild-sys: update gnulib (diff)
downloadportage-utils-0.94.tar.gz
portage-utils-0.94.tar.bz2
portage-utils-0.94.zip
main: ensure correct parsing of key-value pairs in ini-filesv0.94
Ensure the key is terminated when the '=' is adjacent to it (without whitespace). Bug: https://bugs.gentoo.org/851138 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.c b/main.c
index 1337cb0..809a085 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2021 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
@@ -747,7 +747,8 @@ read_one_repos_conf(const char *repos_conf, char **primary)
repo = NULL;
for (p = strtok_r(buf, "\n", &s); p != NULL; p = strtok_r(NULL, "\n", &s))
{
- /* trim trailing whitespace, remove comments, locate = */
+ /* trim trailing whitespace, remove comments, locate =, walking
+ * backwards to the front of the string */
do_trim = true;
e = NULL;
for (r = q = s - 2; q >= p; q--) {
@@ -785,7 +786,7 @@ read_one_repos_conf(const char *repos_conf, char **primary)
for (r = e - 1; r >= p && isspace((int)*r); r--)
*r = '\0';
/* and after the = */
- for (e++; e < q && isspace((int)*e); e++)
+ for (*e++ = '\0'; e < q && isspace((int)*e); e++)
;
if (is_default && strcmp(p, "main-repo") == 0) {