rpm-software-management / librepo

A library providing C and Python (libcURL like) API for downloading packages and linux repository metadata in rpm-md format
http://rpm-software-management.github.io/librepo/
GNU Lesser General Public License v2.1
74 stars 90 forks source link

WITH_ZCHUNK macro affects ABI #298

Closed ppisar closed 4 months ago

ppisar commented 5 months ago

DNF5 was asked to drop a useless dependency on zchunk https://github.com/rpm-software-management/dnf5/issues/1233 because it delegates all zchunk work to librepo. However it turned out that struct LrDownloadTarget ABI defined in <librepo/downloadtarget.h> changes with WITH_ZCHUNK macro.

More over, if the macro is defined, <zck.h> is included albeit librepo-devel RPM package does not depend on zchunk-devel.

All that pushes librepo internals to it users, e.g. to DNF5, and makes the build chain more error prone because the whole aplication stack needs to keep WITH_ZCHUNK in synchronization.

I would appreciate isolating librepo ABI from WITH_ZCHUNK macro.

ppisar commented 5 months ago

I forgot to notice that the biggest mistake of the current code is that compiled librepo has struct LrDownloadTarget of a certain size, but applications including librepo header files without matching WITH_ZCHUNK will see struct LrDownloadTarget of a different size. This can lead to memory corruptions and segfaults.