Petr Písař [Fri, 7 Feb 2025 14:21:16 +0000 (15:21 +0100)]
Fix building in ISO C23
ISO C23 added bool type as a keyword. It is the standard GCC 15 uses by default and
compilation of bindings/perl/solv_perl.c fails then:
bindings/perl/solv_perl.c:1641:13: error: ‘bool’ cannot be defined via ‘typedef’
1641 | typedef int bool;
| ^~~~
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:1: warning: useless type name in empty declaration
1641 | typedef int bool;
| ^~~~~~~
The typedef comes from bindings/solv.i which attemps to supply it in case Swig
undefines it.
This patch fixes it by not defining it in case ISO C23 or newer is in
use. Keywords cannot be checked by a preprocessor, neither undefined
(by Swig).
Make POOL_FLAG_ADDFILEPROVIDESFILTERED behaviour more standard
Turning on POOL_FLAG_ADDFILEPROVIDESFILTERED made the lookup of
all file dependencies lazy, not only the ones required by some
dependency. This changes the way searching works and may also
slow down some use cases.
We now changed addfileprovides() to record the needed non-standard
file dependencies and only make those lazy in createwhatprovides().
Petr Písař [Wed, 10 Jul 2024 14:54:56 +0000 (16:54 +0200)]
Fix a possible format overflow in dump_genid()
GCC 14 called with CFLAGS='-O2 -Wformat-overflow' complains:
/tmp/libsolv/ext/testcase.c: In function ‘dump_genid’:
/tmp/libsolv/ext/testcase.c:1275:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1275:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's indeed a bug: sprintf() writes into a 20-byte array cntbuf. cnt
is int, 32-bit long integer on x86_64 Linux platform. dump_genid()
starts with cnt = 1 and increases. It can go up to 2147483647 decimal
value, then wrap to -2147483648 decimal value. That's up to 11 bytes
of the integer, plus 14 bytes of a static string, plus 1 byte of
a trailing '\0'. 26 bytes in total.
While it's improbable that cnt would amount that long number in real
life, it's better to be prepared for the worst. Also a benefit is that
static analyzers will be be content.
This patch increases cntbuf[] size to accomodate common 32-bit
ints. (Generic, albeit illegible, expression would be:
First resolve the given jobs, then the dependencies of the
resulting packages ignoreing the ones provided by currently
installed packages. After that resolve all already installed
packages. This is similar to SOLVER_FLAG_FOCUS_BEST but less
aggressive in updating packages.
This commit implements the file tree work needed
for the "plaindir" format. Like with the "find" command,
we do not follow symlinks to directories in recursive
mode.
Petr Písař [Mon, 13 May 2024 07:55:01 +0000 (09:55 +0200)]
Report unsupported compression in solv_xfopen() with errno
If libsolv was built without Zstandard support and "primary.xml.zst"
was passed solv_xfopen(), solv_xfopen() returned 0 without setting
errno. A calling application could not distinguish an unsupported
compression format from other I/O errors.
This patch improves this situation by setting errno variable to an
appropriate value. The value macros are documented in POSIX 2017.
getdecisionlist: keep track of all literals from a unit rule
Otherwise, sort_unit_decisions() may not find a unit rule and
go into and endless loop. Before this commit, we left out
conflicted packages to make the decisionlist shorter.
An alternative would be to track those left out literals.
David Cantrell [Tue, 26 Mar 2024 16:13:55 +0000 (12:13 -0400)]
Fix a couple small static analysis findings for uninitialized structs
The memset() on the KeyValue is more explicit even though if you trace
the code you will see it fills out the struct. However, it's possible
that not every struct member will be initialized and adding the
memset() makes things more obvious and appeases the static analyzer.
This seems to be unneeded as the Makefile written by cmake
automatically detects that it needs to rebuild if a different
python version is used. But just be be on the safe side...
Remove the "0:" stripping from the evr in testcase_read. Messing
with the evr is not our business, we need to reproduce the data
as faithful as possible.