pkgconf_pkg_parser_value_set(): fix code-path ordering bug.

Prior to this commit, the code path responsible for prefix redefinition
(motivated by --define-prefix or otherwise) was visited more than
once, specifically since the check ignored pkg->owner->prefix_varname.
master
midipix 2021-06-13 18:38:18 +00:00 committed by Ariadne Conill
parent 1f319c2608
commit 13fe4c8c58
1 changed files with 6 additions and 4 deletions

View File

@ -297,7 +297,11 @@ pkgconf_pkg_parser_value_set(void *opaque, const size_t lineno, const char *keyw
* which is broken when redefining the prefix. We try to outsmart the * which is broken when redefining the prefix. We try to outsmart the
* file and rewrite any directory that starts with the same prefix. * file and rewrite any directory that starts with the same prefix.
*/ */
if (pkg->owner->flags & PKGCONF_PKG_PKGF_REDEFINE_PREFIX && pkg->orig_prefix if (strcmp(keyword, pkg->owner->prefix_varname) || !(pkg->owner->flags & PKGCONF_PKG_PKGF_REDEFINE_PREFIX))
{
pkgconf_tuple_add(pkg->owner, &pkg->vars, keyword, value, true);
}
else if (pkg->owner->flags & PKGCONF_PKG_PKGF_REDEFINE_PREFIX && pkg->orig_prefix
&& is_path_prefix_equal(canonicalized_value, pkg->orig_prefix->value, strlen(pkg->orig_prefix->value))) && is_path_prefix_equal(canonicalized_value, pkg->orig_prefix->value, strlen(pkg->orig_prefix->value)))
{ {
char newvalue[PKGCONF_ITEM_SIZE]; char newvalue[PKGCONF_ITEM_SIZE];
@ -306,8 +310,6 @@ pkgconf_pkg_parser_value_set(void *opaque, const size_t lineno, const char *keyw
pkgconf_strlcat(newvalue, canonicalized_value + strlen(pkg->orig_prefix->value), sizeof newvalue); pkgconf_strlcat(newvalue, canonicalized_value + strlen(pkg->orig_prefix->value), sizeof newvalue);
pkgconf_tuple_add(pkg->owner, &pkg->vars, keyword, newvalue, false); pkgconf_tuple_add(pkg->owner, &pkg->vars, keyword, newvalue, false);
} }
else if (strcmp(keyword, pkg->owner->prefix_varname) || !(pkg->owner->flags & PKGCONF_PKG_PKGF_REDEFINE_PREFIX))
pkgconf_tuple_add(pkg->owner, &pkg->vars, keyword, value, true);
else else
{ {
char pathbuf[PKGCONF_ITEM_SIZE]; char pathbuf[PKGCONF_ITEM_SIZE];
@ -317,7 +319,7 @@ pkgconf_pkg_parser_value_set(void *opaque, const size_t lineno, const char *keyw
{ {
char *prefix_value = convert_path_to_value(relvalue); char *prefix_value = convert_path_to_value(relvalue);
pkg->orig_prefix = pkgconf_tuple_add(pkg->owner, &pkg->vars, "orig_prefix", canonicalized_value, true); pkg->orig_prefix = pkgconf_tuple_add(pkg->owner, &pkg->vars, "orig_prefix", canonicalized_value, true);
pkg->prefix = pkgconf_tuple_add(pkg->owner, &pkg->vars, keyword, prefix_value, false); pkgconf_tuple_add_global(pkg->owner, keyword, prefix_value);
free(prefix_value); free(prefix_value);
} }
else else