Compare commits

...

13 Commits

Author SHA1 Message Date
William Pitcock 0f90104691 pkgconf 1.2.1. 2017-01-23 13:20:48 -06:00
William Pitcock c0accce690 getopt: add some padding to EMSG to avoid overrun 2017-01-23 13:18:31 -06:00
William Pitcock 0c4fec6a83 libpkgconf: use a better check instead of stat() for pkg-config file iteration, avoiding a TOCTOU race condition identified by coverity 2017-01-23 13:18:20 -06:00
William Pitcock b9a80e6780 libpkgconf: iter: check list->tail for null, not list->head 2017-01-23 00:24:37 -06:00
William Pitcock 725df9ce23 Revert "Actually fix the regression introduced in 7b39c38"
This reverts commit 5e5c418837.
2017-01-22 23:52:10 -06:00
William Pitcock f9eb858ce4 libpkgconf: queue: chase API change (mark static root virtual packages as static) 2017-01-22 23:52:03 -06:00
William Pitcock 7e02604500 libpkgconf: split virtual/static package state (this is API/ABI safe, static packages are always treated as virtual when it comes to mutation) 2017-01-22 23:51:55 -06:00
William Pitcock 15ae233d23 tests: add a regression test for #108 2017-01-22 23:51:48 -06:00
William Pitcock 4ea31dc692 libpkgconf: move sys/stat.h inclusion out of stdinc.h to the only other consumer of sys/stat.h 2017-01-22 23:11:15 -06:00
William Pitcock 6f8e414016 libpkgconf: pkg: handle error value from stat(2). 2017-01-22 23:11:09 -06:00
William Pitcock 142a74858f libpkgconf: argvsplit: make escape handling more explicit 2017-01-22 23:11:00 -06:00
Igor Gnatenko e4f47af194 remove dead assignments (#109)
* remove dead assignments

None of them are used.

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>

* The address of an object "&pkgconf_pkg_provides_vermatch_rules[pkgdep->compare]" is never null

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>

* Overrunning array pkgconf_pkg_comparator_names at element index 7

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2017-01-22 22:59:56 -06:00
Baptiste Daroussin 7556285d49 Actually fix the regression introduced in 7b39c38 2017-01-22 22:59:36 -06:00
12 changed files with 54 additions and 26 deletions

10
NEWS
View File

@ -1,6 +1,16 @@
Changes from previous version of pkgconf
========================================
Changes from 1.2.0 to 1.2.1:
----------------------------
* Bug fixes:
- pkg: properly separate static and virtual packages so they are not inappropriately
optimized out of the dependency graph (#108)
* Enhancements:
- many code fixes spotted by coverity
Changes from 1.1.0 to 1.2.0:
----------------------------

View File

@ -12,7 +12,7 @@ dnl implied. In no event shall the authors be liable for any damages arising
dnl from the use of this software.
AC_PREREQ([2.68])
AC_INIT([pkgconf], [1.2.0], [http://github.com/pkgconf/pkgconf/issues])
AC_INIT([pkgconf], [1.2.1], [http://github.com/pkgconf/pkgconf/issues])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([libpkgconf/config.h])
AC_CHECK_FUNCS([strlcpy strlcat strndup realpath cygwin_conv_path])

View File

@ -83,7 +83,8 @@ char *pkg_optarg; /* argument associated with option */
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#define EMSG ""
/* add some padding to EMSG to avoid overrun */
#define EMSG "\0\0\0\0"
#ifdef GNU_COMPATIBLE
#define NO_PREFIX (-1)

View File

@ -124,9 +124,14 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
free(argv);
free(buf);
return -1;
} else {
*dst_iter++ = '\\';
}
else
{
*dst_iter++ = '\\';
*dst_iter++ = *src_iter;
}
break;
default:
*dst_iter++ = *src_iter;
break;

View File

@ -208,7 +208,6 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
compare = PKGCONF_CMP_ANY;
package_sz = 0;
version_sz = 0;
}
break;
@ -254,7 +253,6 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
cnameptr = cmpname;
memset(cmpname, 0, sizeof cmpname);
package_sz = 0;
version_sz = 0;
}
if (state == OUTSIDE_MODULE)

View File

@ -61,7 +61,7 @@ pkgconf_node_insert_tail(pkgconf_node_t *node, void *data, pkgconf_list_t *list)
node->data = data;
if (list->head == NULL)
if (list->tail == NULL)
{
list->head = node;
list->tail = node;

View File

@ -96,11 +96,12 @@ struct pkgconf_path_ {
void *handle_device;
};
#define PKGCONF_PKG_PROPF_NONE 0x0
#define PKGCONF_PKG_PROPF_VIRTUAL 0x1
#define PKGCONF_PKG_PROPF_CACHED 0x2
#define PKGCONF_PKG_PROPF_SEEN 0x4
#define PKGCONF_PKG_PROPF_UNINSTALLED 0x8
#define PKGCONF_PKG_PROPF_NONE 0x00
#define PKGCONF_PKG_PROPF_STATIC 0x01
#define PKGCONF_PKG_PROPF_CACHED 0x02
#define PKGCONF_PKG_PROPF_SEEN 0x04
#define PKGCONF_PKG_PROPF_UNINSTALLED 0x08
#define PKGCONF_PKG_PROPF_VIRTUAL 0x10
struct pkgconf_pkg_ {
pkgconf_node_t cache_iter;

View File

@ -327,7 +327,7 @@ pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename,
void
pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{
if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)
if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC)
return;
pkgconf_cache_remove(client, pkg);
@ -446,14 +446,12 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg
static char filebuf[PKGCONF_BUFSIZE];
pkgconf_pkg_t *pkg;
FILE *f;
struct stat st;
pkgconf_strlcpy(filebuf, path, sizeof filebuf);
pkgconf_strlcat(filebuf, "/", sizeof filebuf);
pkgconf_strlcat(filebuf, dirent->d_name, sizeof filebuf);
stat(filebuf, &st);
if (!(S_ISREG(st.st_mode)))
if (!str_has_suffix(filebuf, PKG_CONFIG_EXT))
continue;
f = fopen(filebuf, "r");
@ -758,7 +756,7 @@ static pkgconf_pkg_t pkg_config_virtual = {
.description = "virtual package defining pkg-config API version supported",
.url = PACKAGE_BUGREPORT,
.version = PACKAGE_VERSION,
.flags = PKGCONF_PKG_PROPF_VIRTUAL,
.flags = PKGCONF_PKG_PROPF_STATIC,
.vars = {
.head = &(pkgconf_node_t){
.prev = NULL,
@ -778,7 +776,7 @@ static pkgconf_pkg_t pkgconf_virtual = {
.description = "virtual package defining pkgconf API version supported",
.url = PACKAGE_BUGREPORT,
.version = PACKAGE_VERSION,
.flags = PKGCONF_PKG_PROPF_VIRTUAL,
.flags = PKGCONF_PKG_PROPF_STATIC,
.vars = {
.head = &(pkgconf_node_t){
.prev = NULL,
@ -923,7 +921,7 @@ static const pkgconf_vercmp_res_func_t pkgconf_pkg_comparator_impls[] = {
const char *
pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep)
{
if (pkgdep->compare > PKGCONF_ARRAY_SIZE(pkgconf_pkg_comparator_names))
if (pkgdep->compare >= PKGCONF_ARRAY_SIZE(pkgconf_pkg_comparator_names))
return "???";
return pkgconf_pkg_comparator_names[pkgdep->compare].name;
@ -1063,9 +1061,6 @@ pkgconf_pkg_scan_provides_vercmp(const pkgconf_dependency_t *pkgdep, const pkgco
{
const pkgconf_pkg_provides_vermatch_rule_t *rule = &pkgconf_pkg_provides_vermatch_rules[pkgdep->compare];
if (rule == NULL)
return false;
if (rule->depcmp[provider->compare] != NULL &&
!rule->depcmp[provider->compare](provider->version, pkgdep->version))
return false;

View File

@ -137,7 +137,7 @@ pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queu
pkgconf_pkg_t world = {
.id = "virtual:world",
.realname = "virtual world package",
.flags = PKGCONF_PKG_PROPF_VIRTUAL,
.flags = PKGCONF_PKG_PROPF_STATIC | PKGCONF_PKG_PROPF_VIRTUAL,
};
/* if maxdepth is one, then we will not traverse deeper than our virtual package. */
@ -178,7 +178,7 @@ pkgconf_queue_validate(pkgconf_client_t *client, pkgconf_list_t *list, int maxde
pkgconf_pkg_t world = {
.id = "virtual:world",
.realname = "virtual world package",
.flags = PKGCONF_PKG_PROPF_VIRTUAL,
.flags = PKGCONF_PKG_PROPF_STATIC | PKGCONF_PKG_PROPF_VIRTUAL,
};
/* if maxdepth is one, then we will not traverse deeper than our virtual package. */

View File

@ -26,7 +26,6 @@
#include <string.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>

View File

@ -23,7 +23,8 @@ tests_init \
idirafter_munge_sysroot \
idirafter_ordering \
pcpath \
sysroot_munge
sysroot_munge \
virtual_variable
case_sensitivity_body()
{
@ -203,3 +204,16 @@ sysroot_munge_body()
-o inline:"-L/sysroot2/sysroot/lib -lfoo \n" \
pkgconf --libs sysroot-dir
}
virtual_variable_body()
{
atf_check -s exit:0 \
pkgconf --exists pkg-config
atf_check -s exit:0 \
pkgconf --exists pkgconf
atf_check -o inline:"${pcpath}\n" \
pkgconf --variable=pc_path pkg-config
atf_check -o inline:"${pcpath}\n" \
pkgconf --variable=pc_path pkgconf
}

View File

@ -6,6 +6,11 @@ if [ "$(uname -s)" = "Msys" ]; then
PATH_SEP=";"
fi
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
pcpath="@PKGCONFIGDIR@"
tests_init()
{
TESTS="$@"