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