public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/dnf5] rawhide: Fix building on 32-bit platforms
@ 2026-08-18 11:47 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-08-18 11:47 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/dnf5
Branch : rawhide
Commit : 2b5bca57a47f98e271a94e8bc955294bbe500e89
Author : Petr Písař <ppisar@redhat.com>
Date   : 2026-08-18T13:46:17+02:00
Stats  : +145/-0 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/dnf5/c/2b5bca57a47f98e271a94e8bc955294bbe500e89?branch=rawhide

Log:
Fix building on 32-bit platforms

---
diff --git a/0001-Fix-integer-overflow-on-32-bit-platforms-in-D-Bus-hi.patch b/0001-Fix-integer-overflow-on-32-bit-platforms-in-D-Bus-hi.patch
new file mode 100644
index 0000000..130e2fe
--- /dev/null
+++ b/0001-Fix-integer-overflow-on-32-bit-platforms-in-D-Bus-hi.patch
@@ -0,0 +1,59 @@
+From 1709c39ac6c8743cbac2160ab028cca2332406a3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Thu, 13 Aug 2026 14:29:04 +0200
+Subject: [PATCH 1/2] Fix integer overflow on 32-bit platforms in D-Bus history
+ limit
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Building on i686 failed:
+
+    /builddir/build/BUILD/dnf5-5.4.3.0-build/dnf5-5.4.3.0/dnf5daemon-server/services/history/history.cpp: In member function ‘sdbus::MethodReply History::list(sdbus::MethodCall&)’:
+    /builddir/build/BUILD/dnf5-5.4.3.0-build/dnf5-5.4.3.0/dnf5daemon-server/services/history/history.cpp:414:51: error: conversion from ‘long long int’ to ‘__gnu_cxx::__normal_iterator<libdnf5::transaction::Transaction*, std::vector<libdnf5::transaction::Transaction> >::difference_type’ {aka ‘int’} may change value [-Werror=conversion]
+      414 |         transactions.erase(transactions.begin() + limit, transactions.end());
+	  |                                                   ^~~~~
+
+The cause was right-hand side of "+" operator after an iterator requires a
+ptrdiff_t type, which is 32-bit signed int on 32-bit platforms. Hence the
+compiler correctly complained that a limit value larger than 2^31-1 could be
+misinterpreted when coercing 64-bit signed limit variable.
+
+This patch adds thetype cast to placate the compiler and the necessary check
+for the maximal representiable value for ptrdiff_t. It also adds a missing
+uppper bound check for size_t type.
+---
+ dnf5daemon-server/services/history/history.cpp | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/dnf5daemon-server/services/history/history.cpp b/dnf5daemon-server/services/history/history.cpp
+index 3460748a5..789858fce 100644
+--- a/dnf5daemon-server/services/history/history.cpp
++++ b/dnf5daemon-server/services/history/history.cpp
+@@ -34,7 +34,10 @@
+ #include <libdnf5/utils/format.hpp>
+ #include <sdbus-c++/sdbus-c++.h>
+ 
++#include <cstddef>
++#include <limits>
+ #include <unordered_map>
++#include <utility>
+ 
+ namespace {
+ 
+@@ -410,8 +413,10 @@ sdbus::MethodReply History::list(sdbus::MethodCall & call) {
+     }
+ 
+     // Apply limit
+-    if (limit > 0 && transactions.size() > static_cast<size_t>(limit)) {
+-        transactions.erase(transactions.begin() + limit, transactions.end());
++    if (limit > 0 && std::cmp_less(limit, std::numeric_limits<size_t>::max()) &&
++        std::cmp_less(limit, std::numeric_limits<ptrdiff_t>::max()) &&
++        transactions.size() > static_cast<size_t>(limit)) {
++        transactions.erase(transactions.begin() + static_cast<ptrdiff_t>(limit), transactions.end());
+     }
+ 
+     // Build output
+-- 
+2.55.0
+

diff --git a/0002-reposync-Prevent-a-min-buildtime-overflow-on-32-bit-.patch b/0002-reposync-Prevent-a-min-buildtime-overflow-on-32-bit-.patch
new file mode 100644
index 0000000..549f24e
--- /dev/null
+++ b/0002-reposync-Prevent-a-min-buildtime-overflow-on-32-bit-.patch
@@ -0,0 +1,84 @@
+From 988d838cdcd97760d6733e5d29b3de02c971af62 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Thu, 13 Aug 2026 17:00:00 +0200
+Subject: [PATCH 2/2] reposync: Prevent a --min-buildtime overflow on 32-bit
+ platforms
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Compilation on i686 failed:
+
+    /builddir/build/BUILD/dnf5-5.4.3.0-build/dnf5-5.4.3.0/dnf5-plugins/reposync_plugin/reposync.cpp: In member function ‘dnf5::ReposyncCommand::download_list_type dnf5::ReposyncCommand::get_packages_list(const libdnf5::repo::Repo&)’:
+    /builddir/build/BUILD/dnf5-5.4.3.0-build/dnf5-5.4.3.0/dnf5-plugins/reposync_plugin/reposync.cpp:247:60: error: conversion from ‘int64_t’ {aka ‘long long int’} to ‘time_t’ {aka ‘long int’} may change value [-Werror=conversion]
+      247 |         query.filter_recent(min_buildtime_option->get_value());
+	  |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
+
+The cause was a disagreement between
+libdnf5::cli::session::DateOption::get_value() type (int64_t) and
+PackageQuery::filter_recent() type (time_t).
+
+This quick fix was choosen becaue it does not changes API in any way.
+
+Ideal fix would be either changing
+libdnf5::cli::session::DateOption::get_value() type or adding yet another
+PackageQuery::filter_recent() accepting int64_t. (We could make a template, but
+would not have to forget on adding few instances into language bindings.)
+
+Less deal fix would be adding libdnf5::cli::session::DateOption::get_value()
+which returns time_t, so tthat we can stop usning type casts through out the
+code.
+---
+ dnf5-plugins/reposync_plugin/reposync.cpp |  2 +-
+ libdnf5-cli/session.cpp                   | 14 +++++++++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/dnf5-plugins/reposync_plugin/reposync.cpp b/dnf5-plugins/reposync_plugin/reposync.cpp
+index 4c720f307..1fe30639d 100644
+--- a/dnf5-plugins/reposync_plugin/reposync.cpp
++++ b/dnf5-plugins/reposync_plugin/reposync.cpp
+@@ -244,7 +244,7 @@ ReposyncCommand::download_list_type ReposyncCommand::get_packages_list(const lib
+     }
+ 
+     if (min_buildtime_option->get_arg()->get_parse_count() >= 1) {
+-        query.filter_recent(min_buildtime_option->get_value());
++        query.filter_recent(static_cast<time_t>(min_buildtime_option->get_value()));
+     }
+ 
+     if (!arch_option.empty()) {
+diff --git a/libdnf5-cli/session.cpp b/libdnf5-cli/session.cpp
+index c8ac211d8..b2fa196c1 100644
+--- a/libdnf5-cli/session.cpp
++++ b/libdnf5-cli/session.cpp
+@@ -22,7 +22,9 @@
+ #include <libdnf5/utils/bgettext/bgettext-mark-domain.h>
+ 
+ #include <chrono>
++#include <limits>
+ #include <sstream>
++#include <utility>
+ 
+ namespace libdnf5::cli::session {
+ 
+@@ -257,7 +259,17 @@ DateOption::DateOption(
+                     throw libdnf5::cli::ArgumentParserError(
+                         M_("Invalid date passed: \"{}\". Dates in \"YYYY-MM-DD\" format are expected"), value);
+                 }
+-                return tp.time_since_epoch().count();
++                // This option should have used time_t because it is used
++                // elsewhere, e.g. in PackageQuery::filter_recent().
++                // Therefore reject out-of-range values right now instead of
++                // dealing with the overflows throughout the code.
++                auto numeric_value = tp.time_since_epoch().count();
++                if (std::cmp_less(numeric_value, std::numeric_limits<time_t>::lowest()) ||
++                    std::cmp_greater(numeric_value, std::numeric_limits<time_t>::max())) {
++                    throw libdnf5::cli::ArgumentParserError(
++                        M_("\"{}\" date cannot be represented by time_t type on this platform"), value);
++                }
++                return numeric_value;
+             }))));
+     arg->link_value(conf);
+ 
+-- 
+2.55.0
+

diff --git a/dnf5.spec b/dnf5.spec
index 11ed9a0..bf0a1ea 100644
--- a/dnf5.spec
+++ b/dnf5.spec
@@ -18,6 +18,8 @@ Summary:        Command-line package manager
 License:        GPL-2.0-or-later
 URL:            https://github.com/rpm-software-management/dnf5
 Source0:        %{url}/archive/%{version}/dnf5-%{version}.tar.gz
+Patch1:         0001-Fix-integer-overflow-on-32-bit-platforms-in-D-Bus-hi.patch
+Patch2:         0002-reposync-Prevent-a-min-buildtime-overflow-on-32-bit-.patch
 
 Requires:       libdnf5%{?_isa} = %{version}-%{release}
 Requires:       libdnf5-cli%{?_isa} = %{version}-%{release}

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-18 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-18 11:47 [rpms/dnf5] rawhide: Fix building on 32-bit platforms 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox