libpkgconf/pkg.c


Log

Author Commit Date CI Message
Taylor R Campbell 212c8586 2023-03-17T19:32:58 Avoid undefined behaviour with the ctype(3) functions. fix https://github.com/pkgconf/pkgconf/issues/291 As defined in the C standard: In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined. This is because they're designed to work with the int values returned by getc or fgetc; they need extra work to handle a char value. If EOF is -1 (as it almost always is), with 8-bit bytes, the allowed inputs to the ctype(3) functions are: {-1, 0, 1, 2, 3, ..., 255}. However, on platforms where char is signed, such as x86 with the usual ABI, code like char *ptr = ...; ... isspace(*ptr) ... may pass in values in the range: {-128, -127, -126, ..., -2, -1, 0, 1, ..., 127}. This has two problems: 1. Inputs in the set {-128, -127, -126, ..., -2} are forbidden. 2. The non-EOF byte 0xff is conflated with the value EOF = -1, so even though the input is not forbidden, it may give the wrong answer. Casting char to unsigned int first before passing the result to ctype(3) doesn't help: inputs like -128 are unchanged by this cast, because (on a two's-complement machine with 32-bit int and unsigned int), converting the signed char with integer value -128 to unsigned int gives integer value 2^32 - 128 = 0xffffff80, which is out of range, and which is converted in int back to -128, which is also out of range. It is necessary to cast char inputs to unsigned char first; you can then cast to unsigned int if you like but there's no need because the functions will always convert the argument to int by definition. So the above fragment needs to be: char *ptr = ...; ... isspace((unsigned char)*ptr) ... This patch changes unsigned int casts to unsigned char casts, and adds unsigned char casts where they are missing.
Ariadne Conill d9e507cc 2023-01-21T21:31:38 pkg: do not do serial checks for flattened solutions, as they are already flattened
Ariadne Conill e2a12fd4 2023-01-21T20:39:53 main: reset solver when solving for library groups
Doug Freed 08db74c4 2022-10-12T21:43:52 pkg: make pkgconf_compare_version consistent The code taken from rpmvercmp in pkg-config returns -1 if a is less than b, 0 if a is equal to b, and 1 if a is greater than b. This matches the expectations of the comparison operators that use this function. However, the tilde handling, the NULL handling, and the docstring all do the opposite. This fixes the tilde handling, the NULL handling, and the docstring to match the behavior of the rpmvercmp code and the expectations of the comparison operators.
Ariadne Conill ced9bee6 2022-08-16T18:51:11 pkg: remove dead store in pkgconf_compare_version
Ariadne Conill 696124b6 2022-08-12T12:36:21 pkg: add support for parsing the URL from pc files
Ariadne Conill aa99ddf7 2022-08-11T15:52:33 pkg: add Copyright and Maintainer fields These are helpful pieces of information for BOM documents generated by pkgconf.
Ariadne Conill 28b5d57b 2022-08-08T10:25:24 pkg: free SPDX license tags when a package is destroyed
Ariadne Conill 7e9aa7e1 2022-08-08T09:56:28 pkg: do not break cycles across dependency lists
Ariadne Conill 69f630aa 2022-08-08T09:34:45 pkg: only advance serial if we are actually traversing from a root
Ariadne Conill 0e05308f 2022-08-07T04:35:29 pkg: add SPDX license assertion to pkgconf builtin
Ariadne Conill 1389aa05 2022-08-07T04:21:22 pkg: add pkgconf_pkg_t.license field The pkgconf_pkg_t.license field maps to the new License keyword, and should be an SPDX license expression.
Ariadne Conill 7edfdbff 2022-08-07T01:29:21 pkg: upgrade circular reference trace to a warning
Ariadne Conill 662668d0 2022-08-07T01:09:07 pkg: add trace log when breaking a circular reference
Dylan Baker 1cfa2d1e 2022-08-04T15:16:44 pkg: prevent circular ownership Otherwise in a case where A references B, and B references A, A and B will have mutual ownership of each other and prevent each other from being free'd.
Dylan Baker 49342057 2022-08-04T11:50:50 pkg: add name of pkg being refed/unrefed to debug outpu
Dylan Baker a391f9b6 2022-08-03T16:32:35 pkg: use goto cleanup idiom
Dylan Baker 4a1119aa 2022-08-03T15:43:04 dependency: Fix reference counting of dependency_addraw We only want a reference to be added for the value inserted into the list, not the one returned. The returned one is unowned until it reaches the public dependency_add function, which returns an owned pointer instead. This makes things semantically more correct. Unfortunately, this means in a few cases we have to write some ugly code like: ```c pkgconf_dependency_t *dep = pkgcond_dependency_add("args"); pkgconf_dependency_unref(dep->owner, dep); ```
Ariadne Conill f8aefea7 2022-07-26T17:13:15 pkg: add flags argument to pkgconf_pkg_new_from_file
Ariadne Conill 297e18f2 2022-07-26T17:08:48 tuple: add flags parameter to pkgconf_tuple_parse
Ariadne Conill b0802cb3 2022-06-26T19:41:31 Revert "pkgconf_pkg_parser_value_set(): fix code-path ordering bug." This reverts commit 13fe4c8c589be99b12db62b053c38124afecf2d7.
Ariadne Conill a61193c7 2022-06-26T19:16:00 pkg: fix sysroot_dir logic for github 213
Ariadne Conill 5817e884 2022-06-26T07:22:56 pkg: track the number of hits a package has gotten while solving for dependencies
Ariadne Conill 6ae17bd0 2022-06-26T06:05:40 pkg: split pkgconf_pkg_traverse into a serial-modifying version
Ariadne Conill 2b82a4f6 2021-10-07T00:23:35 use a serial instead of PKGCONF_PKG_PROPF_SEEN
Ariadne Conill c547edd0 2021-10-06T11:52:18 deconst the client on pkgconf_dependency_add()
Ariadne Conill ceece2c1 2021-07-24T19:47:33 pkg: fix up comment about issue #213 workaround
Sandro Mani ed86f2dd 2021-06-23T14:09:05 Don't prepend sysroot_dir if pkg-config file lies outside of sysroot_dir
midipix 13fe4c8c 2021-06-13T18:38:18 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.
Christoph Reiter 4f73f6a1 2021-03-20T11:01:14 Rework path handling on native Windows The current approach was to parse the .pc and, detect the prefix, throw everything together and at the end replace all \ with / to not produce invalid escape sequences. This has the problem that escaping in .pc files is ignored and no longer possible. Also in case the prefix path has a space in it the result would be invalid because of missing escaping. This changes the following things: * We no longer normalize values at the end. Instead we assume .pc files use "/" as a directory separator or "\\", same format as under Unix. "\" alone no longer works. This shouldn't be a problem since most build tools produce .pc files with "/" like meson, cmake, autotools. * When injecting the prefix at runtime we convert the prefix to use "/" and escape spaces so that in combination with the .pc content the result is a valid escaped path value again. This patch has been used in MSYS2 for some months now. See #212
Ryan Scott ab404bc2 2021-02-03T06:54:52 Fix #209 This commit fixes #209 by applying the suggestion from https://github.com/pkgconf/pkgconf/issues/209#issuecomment-771609136.
Christoph Reiter 869f2a84 2020-11-28T16:01:16 pkgconf_pkg_parser_version_func: fix whitespace detection In case the version string has no whitespace then strcspn() returns strlen() of the input, so whitespace is only found if len != strlen. This fixes invalid warnings when parsing version fields.
Tobias Stoeckmann f818a69b 2020-06-03T21:42:25 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
Ariadne Conill c613eb5c 2020-05-26T13:41:39 libpkgconf: pkg: use a second pointer for demunging windows paths
Ariadne Conill e70b536e 2020-05-26T11:01:46 libpkgconf: pkg: when generating a search path, use the correct path separator Before, this could result in generated paths like C:\foo\pkgconfig/bar.pc on Windows.
Ariadne Conill 0253fddc 2020-05-26T07:41:16 libpkgconf: pkg: fix computation of pkgconf_pkg_t.id on Windows. Windows allows both \ and / as valid path characters. A computed path such as C:\development\libfoo\pkgconfig/foo.pc will result in a computed pkgconf_pkg_t.id of "pkgconfig/foo". Accordingly, correct the path normalization for checking for / after the \ path has been dealt with in all cases.
Ben 011db1bb 2020-04-26T17:28:03 Do not complain about malformed whitespace from \n on Version line Every version line has a newline at the end; the malformed whitespace checker should just check for trailing spaces and tabs. Resolves https://todo.sr.ht/~kaniini/pkgconf/15
Ariadne Conill 382a89c1 2020-05-24T14:18:16 pkg: pkgconf_compare_version(): do not return levenshtein distance in strcmp() case
Ariadne Conill c10f6999 2019-07-12T06:35:48 libpkgconf: pkg: generate diagnostic for and trim malformed versions
Alexander Tsoy db9c1e96 2019-06-07T19:19:28 fix the order of header includes config.h should be included before stdinc.h, otherwise large file support is not enabled. Downstream bug: https://bugs.gentoo.org/687548
William Pitcock 6854265f 2019-01-14T13:48:23 libpkgconf: pkg: use pkgconf_fragment_copy_list() to clean up cflags gathering logic (closes #20)
William Pitcock 0ae52182 2019-01-14T13:11:59 libpkgconf: pkg: clean up pkgconf_parser interactions (closes #13)
Ignacio Casal Quinteiro 2c059710 2018-09-17T15:20:28 Canonicalize paths before using them This fixes a problem where on Windows the prefix would not match if the prefix is generated with backslashes and the rest of the variables use normal slashes
Ignacio Casal Quinteiro 9f17da92 2018-09-17T15:20:00 On Windows the path prefix should be checked caseless
William Pitcock 6f05fec4 2018-06-16T16:35:44 pkg: give a correctly sized vtable to the parser
William Pitcock 1244f8f8 2018-05-09T21:21:39 libpkgconf: refactor out the rfc822 message parser so that the cross-personality code can share it
William Pitcock f702967d 2018-05-09T19:56:30 libpkgconf: pkg: refactor pkgconf_pkg_new_from_file to prepare to factor out the rfc822 parser
William Pitcock 0f17a4f3 2018-05-09T19:33:12 libpkgconf: pkg: mark owning client earlier, to allow for refactoring out the rfc822 parser
William Pitcock 6b0e346c 2018-05-09T17:07:26 libpkgconf: refactor building the dir lists into separate concerns
Leorize f36ccc1d 2018-04-03T12:46:35 libpkgconf: add support for Haiku client: use BELIBRARIES On Haiku, BELIBRARIES is the equivalent to LIBRARY_PATH on many other systems, while LIBRARY_PATH is instead the LD_LIBRARY_PATH of Haiku. pkg: bootstrap package search paths with Haiku's find_paths This commit adds build_default_pkgconfig_path. The function appends to the list given the default pkgconfig paths, and will supersede get_default_pkgconfig_path
William Pitcock 7e9ed692 2018-03-18T18:04:02 libpkgconf: pkg: skip over -I cflags from Requires.internal nodes when building a cflags list
William Pitcock f03ec3ff 2018-03-18T15:46:53 libpkgconf: add support for proposed Requires.internal extension
TingPing a50bf726 2018-03-08T05:16:18 Fix incorrect comment (#178)
TingPing 60c05f56 2018-03-08T05:00:22 Improve prefix rewriting on Windows (#177) * cli: Default to rewriting prefix on Windows This matches `pkg-config` behavior * libpkgconf: Rewrite the prefix of all variables
William Pitcock 0d523391 2018-02-08T14:25:47 libpkgconf: pkg: ensure the dependency node has a solution associated with it Sometimes this did not happen, e.g. when using providers as the solution (ref #172).
William Pitcock 4a09efe0 2018-01-05T11:38:21 libpkgconf: pkg: fix harmless gcc7 compiler warning
William Pitcock a42f265c 2017-12-21T02:18:50 libpkgconf: pkg: include system libdir and includedir search paths as variables in builtin packages (closes #165)
William Pitcock e0bf4009 2017-12-12T00:21:21 libpkgconf: pkg: rename pkgconf_pkg_t.requires to pkgconf_pkg_t.required (closes #154) C++20 makes requires a keyword, so we need to not use it in headers.
William Pitcock f7406afc 2017-12-05T18:04:42 libpkgconf: pkg: do not mention PKG_CONFIG_SKIP_CONFLICTS env var when simplified errors are requested (closes #134)
William Pitcock 74d58d1b 2017-12-05T17:34:01 libpkgconf: pkg: cache solutions for already solved dependency graph nodes in almost all cases, we partially solve the dependency graph multiple times, which just wastes resources. if we record the solution to a given dependency node, further iterations can make use of the previous solution without having to solve it again. this is safe because all provides entries (including virtuals) are knowable prior to solving the dependency graph the first time. a nice side effect of this is that all packages are preloaded when querying information about them (--cflags and related commands).
William Pitcock 44b4b126 2017-12-05T17:32:00 libpkgconf: pkg: record which pkgconf_client_t owns each pkgconf_pkg_t object
William Pitcock 4c0cc292 2017-12-05T17:24:57 libpkgconf: pkg: add refcount debugging
William Pitcock 4589274c 2017-10-16T12:56:19 libpkgconf: start to remove PKGCONF_BUFSIZE allocations from the stack. (closes #149) Patch by Karen Arutyunov.
William Pitcock 420c62e1 2017-09-19T21:58:54 libpkgconf: pkg: refactor parser harness to allow providing warnings, provide warning for improper fragment list
William Pitcock e9fd43ca 2017-09-17T23:38:25 libpkgconf: clean up header includes (closes #137)
William Pitcock f808300a 2017-09-13T14:56:10 libpkgconf: pkg: some elements of virtual packages should be freed as they have heap-allocated portions (closes #132)
William Pitcock 9b55fc3c 2017-09-13T14:41:00 libpkgconf: cache: refactor the way package objects are marked as cached to avoid memory leaks (#133)
William Pitcock b7839f6b 2017-09-08T20:06:52 libpkgconf: pkg: pkgconf_pkg_scan_dir: remove unnecessary static declaration of filebuf
William Pitcock 2681c29e 2017-09-08T20:04:49 libpkgconf: pkg: determine_prefix: use caller-provided buffer for reentrancy
William Pitcock adae7044 2017-09-08T20:01:34 libpkgconf: pkg: get_default_pkgconfig_path: use caller-supplied buffer for reentrancy
William Pitcock 615bab3d 2017-09-08T19:48:31 libpkgconf: pkg: pkgconf_pkg_report_graph_error(): move already_sent_notice to pkgconf_client_t
William Pitcock b0ef708e 2017-09-08T19:23:04 libpkgconf: pkg: pkg_get_parent_dir(): use caller-supplied buffer instead of a static buffer to make reentrant
William Pitcock 47ce9765 2017-09-08T18:44:28 libpkgconf: define SIZE_FMT_SPECIFIER on POSIX and Windows platforms and use it in place of %zu The MSVCRT runtime as used on Windows does not support %zu, but instead recommends %Iu. As we want to remain portable to other runtimes, even on Windows, we do not use %Iu, but instead expand it logically to either %lu or %llu depending on if it's _WIN32 or _WIN64 headers. On POSIX, we assume C99 support is available and always use %zu, as pkgconf has never supported anything earlier than C99 officially. Closes #125.
William Pitcock 864b14e5 2017-06-16T21:06:01 Merge branch 'cmakeify' of github.com:dankegel/pkgconf
William Pitcock 03f78410 2017-06-16T15:27:23 libpkgconf: pkg: windows can use either \ or / as directory separators ref #118
William Pitcock d45e8501 2017-06-16T13:03:51 Revert "pkg: use pkgconf_pkg_t.realname instead of pkgconf_pkg_t.id for injecting the default provides entry" This reverts commit 0c22b4d8a1596e1d5b261041c36b474d05783373.
William Pitcock 0c22b4d8 2017-06-16T11:49:26 pkg: use pkgconf_pkg_t.realname instead of pkgconf_pkg_t.id for injecting the default provides entry This issue was noticed while porting pkgconf to Windows. ref #118
Dan Kegel 794aa501 2017-06-05T20:54:57 Tidy up a bit.
Dan Kegel 4d7b4d7c 2017-06-04T19:19:55 Minimal tweaks to compile with Visual C 2015
William Pitcock d280060e 2017-05-19T23:37:57 libpkgconf: pkg: add additional validation rules in post-parse phase
William Pitcock 0262b825 2017-05-19T23:33:49 libpkgconf: pkgconf_pkg_find(): correctly handle failure from pkgconf_pkg_new_from_file()
William Pitcock cf3c50ca 2017-05-19T23:21:58 libpkgconf: pkg: pkgconf_try_specific_path() and pkgconf_pkg_new_from_file() require a mutable client to release resources when encountering invalid packages
William Pitcock acac1f8e 2017-03-24T00:59:53 libpkgconf: pkg: show iteration depth when traversing
William Pitcock 81011ba5 2017-02-27T09:54:02 main: implement --short-errors (#115)
William Pitcock 794443a9 2017-02-25T16:04:55 dependency: break API to add tracepoints to dependency list building
William Pitcock e0c9569f 2017-02-25T15:53:50 fragment: add tracepoints
William Pitcock b0c36cd1 2017-02-04T20:35:49 libpkgconf: pkg: add some trace points
William Pitcock 820ad83e 2017-02-04T19:03:33 libpkgconf: pkg: add variable whitespace warnings back, using pkgconf_warn().
William Pitcock 1aa1a433 2017-01-26T13:38:57 Revert "libpkgconf: pkg: warn when encountering trailing whitespace" This reverts commit 2fa4fd09d02905e07397c2617bb1be735f6cd96b.
William Pitcock 2fa4fd09 2017-01-26T13:32:07 libpkgconf: pkg: warn when encountering trailing whitespace
William Pitcock ef1503b7 2017-01-26T13:10:52 libpkgconf: strip trailing whitespace
William Pitcock e87595b3 2017-01-23T12:42:13 libpkgconf: use a better check instead of stat() for pkg-config file iteration, avoiding a TOCTOU race condition identified by coverity
William Pitcock 0927ecf1 2017-01-22T23:29:59 Revert "Actually fix the regression introduced in 7b39c38" This reverts commit 5e5c418837b569196cc17eb999b3c11a9cc0099d.
William Pitcock 0c01a812 2017-01-22T23:26:01 libpkgconf: split virtual/static package state (this is API/ABI safe, static packages are always treated as virtual when it comes to mutation)
William Pitcock 9ece7cd4 2017-01-22T23:09:38 libpkgconf: move sys/stat.h inclusion out of stdinc.h to the only other consumer of sys/stat.h
William Pitcock e5f3dac6 2017-01-22T23:07:39 libpkgconf: pkg: handle error value from stat(2).
Igor Gnatenko 5db87c96 2017-01-22T20:31:34 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>
Baptiste Daroussin 5e5c4188 2017-01-22T11:25:05 Actually fix the regression introduced in 7b39c38
Baptiste Daroussin 17be554a 2017-01-22T11:23:24 Revert "Fix regression introduced in 7b39c38" This reverts commit 7d89f659ffa45d381c3c4ee03c55f74635042829.
Baptiste Daroussin 7d89f659 2017-01-22T10:44:09 Fix regression introduced in 7b39c38 now pkgconf --variable=pc_path pkg-config works