diff options
author | Fabian Groffen <grobian@gentoo.org> | 2022-06-14 08:35:35 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2022-06-14 08:35:35 +0200 |
commit | 2100df5c171029d6c347650fdaf098b67df0f059 (patch) | |
tree | 36e4432a495bbccf364fb284205d6f156ed63bee | |
parent | build-sys: update gnulib (diff) | |
download | portage-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.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) { |