libpkgconf: pkg: fix out ouf boundary access

If a file with a matching "uninstalled" name exists but cannot be
parsed, an invalid memory area is accessed.

How to reproduce:
$ touch poc-uninstalled.pc
$ PKG_CONFIG_PATH=. pkgconf poc
master
Tobias Stoeckmann 2020-06-03 21:42:25 +02:00 committed by Ariadne Conill
parent ef135d819c
commit f818a69b3d
1 changed files with 2 additions and 1 deletions

View File

@ -539,6 +539,7 @@ pkgconf_pkg_try_specific_path(pkgconf_client_t *client, const char *path, const
{ {
PKGCONF_TRACE(client, "found (uninstalled): %s", uninst_locbuf); PKGCONF_TRACE(client, "found (uninstalled): %s", uninst_locbuf);
pkg = pkgconf_pkg_new_from_file(client, uninst_locbuf, f); pkg = pkgconf_pkg_new_from_file(client, uninst_locbuf, f);
if (pkg != NULL)
pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED; pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED;
} }
else if ((f = fopen(locbuf, "r")) != NULL) else if ((f = fopen(locbuf, "r")) != NULL)