public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-block/gparted/, sys-block/gparted/files/
@ 2022-04-21 23:12 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2022-04-21 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     d1a95e7e586a51f7485fe2db57ffaf62e8333b2f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 21 23:11:13 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Apr 21 23:12:45 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d1a95e7e

sys-block/gparted: fix build with musl-1.2.3

Closes: https://bugs.gentoo.org/838466
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../gparted/files/gparted-1.3.1-musl-nullptr.patch | 51 ++++++++++++++++++++++
 sys-block/gparted/gparted-1.3.1.ebuild             |  6 ++-
 sys-block/gparted/gparted-1.4.0.ebuild             |  4 ++
 3 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/sys-block/gparted/files/gparted-1.3.1-musl-nullptr.patch b/sys-block/gparted/files/gparted-1.3.1-musl-nullptr.patch
new file mode 100644
index 000000000000..2a4f648db609
--- /dev/null
+++ b/sys-block/gparted/files/gparted-1.3.1-musl-nullptr.patch
@@ -0,0 +1,51 @@
+https://gitlab.gnome.org/GNOME/gparted/-/commit/3d4b1c1e7b33f229efd254fb0cc06660af627ea0
+https://bugs.gentoo.org/838466
+
+From: Dominika Liberda <ja@sdomi.pl>
+Date: Sun, 10 Apr 2022 21:09:56 +0200
+Subject: [PATCH] Fix NULL == 0 assumption in call to ped_partition_flag_next()
+ (!100)
+
+GParted fails to build on Alpine Linux Edge (development tree for the
+next release) like this:
+
+    GParted_Core.cc: In constructor 'GParted::GParted_Core::GParted_Core()':
+    GParted_Core.cc:75:64: error: invalid 'static_cast' from type 'std::nullptr_t' to type 'PedPartitionFlag'
+       75 |     for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
+          |                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The code is failing to compile now because musl libc 1.2.3 has became
+more C++11 strict [1][2] by defining NULL [3] as nullptr [4] rather than
+as 0.  The parameter to ped_partition_flag_next() [5] should always have
+been numeral 0 cast to an enumeration and never the NULL pointer.
+
+Fixes this commit [6] from 2004-12-27 which changed the parameter from 0
+to NULL.
+
+[1] define NULL as nullptr when used in C++11 or later
+    https://git.musl-libc.org/cgit/musl/commit?id=98e688a9da5e7b2925dda17a2d6820dddf1fb28
+[2] NULL vs nullptr (Why was it replaced?) [duplicate]
+    https://stackoverflow.com/questions/20509734/null-vs-nullptr-why-was-it-replaced
+[3] C++ reference, NULL
+    https://en.cppreference.com/w/cpp/types/NULL
+[4] C++ reference, nullptr
+    https://en.cppreference.com/w/cpp/language/nullptr
+[5] libparted Documentation, ped_partition_flag_next()
+    https://www.gnu.org/software/parted/api/group__PedPartition.html#g0ce9ce4247b320011bc8e9d957c8cdbb
+[6] Added cylsize to Device and made Operation contain a Device instead
+    commit 174f0cff77c5799a713954a22b2c54306d03036c
+
+Closes !100 - Fix NULL == 0 assumption in call to
+              ped_partition_flag_next()
+--- a/src/GParted_Core.cc
++++ b/src/GParted_Core.cc
+@@ -72,7 +72,7 @@ GParted_Core::GParted_Core()
+ 	ped_exception_set_handler( ped_exception_handler ) ; 
+ 
+ 	//get valid flags ...
+-	for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
++	for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( 0 ) ) ;
+ 	      flag ;
+ 	      flag = ped_partition_flag_next( flag ) )
+ 		flags .push_back( flag ) ;
+GitLab

diff --git a/sys-block/gparted/gparted-1.3.1.ebuild b/sys-block/gparted/gparted-1.3.1.ebuild
index 1368424f32cc..1119005c1bb3 100644
--- a/sys-block/gparted/gparted-1.3.1.ebuild
+++ b/sys-block/gparted/gparted-1.3.1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -35,6 +35,10 @@ BDEPEND="
 	virtual/pkgconfig
 "
 
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.3.1-musl-nullptr.patch
+)
+
 src_configure() {
 	gnome2_src_configure \
 		--enable-doc \

diff --git a/sys-block/gparted/gparted-1.4.0.ebuild b/sys-block/gparted/gparted-1.4.0.ebuild
index 1a1cd973c18d..a209f0a714db 100644
--- a/sys-block/gparted/gparted-1.4.0.ebuild
+++ b/sys-block/gparted/gparted-1.4.0.ebuild
@@ -35,6 +35,10 @@ BDEPEND="
 	virtual/pkgconfig
 "
 
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.3.1-musl-nullptr.patch
+)
+
 src_configure() {
 	gnome2_src_configure \
 		--enable-doc \


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: sys-block/gparted/, sys-block/gparted/files/
@ 2025-07-04 20:38 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2025-07-04 20:38 UTC (permalink / raw
  To: gentoo-commits

commit:     2c5af6ad58efbe57449ebc249d71374e62b1c435
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  4 20:35:34 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jul  4 20:37:38 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2c5af6ad

sys-block/gparted: fix crash w/ broken icons

In this case, the crash seems to have been because gdk-pixbuf was broken
(where the root cause is being investigated in bug #959479). But nonetheless,
should it be broken for any reason (diff reason in Debian where this first
came up), we shouldn't crash. Backport the fix for that.

Bug: https://bugs.gentoo.org/959479
Closes: https://bugs.gentoo.org/959434
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../gparted-1.6.0-handle-failing-pixbuf.patch      | 79 ++++++++++++++++++++++
 ...ted-1.6.0-r1.ebuild => gparted-1.6.0-r2.ebuild} |  2 +-
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/sys-block/gparted/files/gparted-1.6.0-handle-failing-pixbuf.patch b/sys-block/gparted/files/gparted-1.6.0-handle-failing-pixbuf.patch
new file mode 100644
index 000000000000..5b4cf0b0f487
--- /dev/null
+++ b/sys-block/gparted/files/gparted-1.6.0-handle-failing-pixbuf.patch
@@ -0,0 +1,79 @@
+https://bugs.gentoo.org/959434
+https://bugs.debian.org/984953
+https://gitlab.gnome.org/GNOME/gparted/-/issues/282
+https://gitlab.gnome.org/GNOME/gparted/-/commit/6cd9690426ba576a22a5a48cae5684c542629591
+
+From 6cd9690426ba576a22a5a48cae5684c542629591 Mon Sep 17 00:00:00 2001
+From: Mike Fleetwood <mike.fleetwood@googlemail.com>
+Date: Sun, 1 Jun 2025 15:08:57 +0100
+Subject: [PATCH] Fix crash from dereferencing a nullptr in Utils::mk_pixbuf()
+ (#282)
+
+Debian bug 984953 [1] reported a crash from a nullptr dereference.  The
+captured backtrace was:
+    (gdb) backtrace
+    #0  Gdk::Pixbuf::gobj (this=0x0) at ../gdkmm/pixbuf.h:389
+    #1  Gdk::Pixbuf::get_width (this=0x0) at pixbuf.cc:517
+    #2  0x0000aaaaaab89ca4 in GParted::Utils::mk_pixbuf (widget=..., stock_id=..., icon_size=..., icon_size@entry=...) at /usr/include/glibmm-2.4/glibmm/refptr.h:259
+    #3  0x0000aaaaaab92020 in GParted::Win_GParted::refresh_combo_devices (this=0xffffffffe960) at /usr/include/gtkmm-3.0/gtkmm/enums.h:2870
+    #4  0x0000aaaaaab95980 in GParted::Win_GParted::menu_gparted_refresh_devices (this=<optimized out>) at Win_GParted.cc:1674
+    #5  0x0000aaaaaab95e2c in GParted::Win_GParted::initial_device_refresh (data=<optimized out>) at Win_GParted.cc:1605
+    #6  0x0000fffff6b8dab4 in g_main_dispatch (context=0xaaaaaaca6f10) at ../../../glib/gmain.c:3325
+    #7  g_main_context_dispatch (context=0xaaaaaaca6f10) at ../../../glib/gmain.c:4043
+    #8  0x0000fffff6b8de5c in g_main_context_iterate (context=0xaaaaaaca6f10, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../glib/gmain.c:4119
+    #9  0x0000fffff6b8e1b0 in g_main_loop_run (loop=loop@entry=0xaaaaabb23860) at ../../../glib/gmain.c:4317
+    #10 0x0000fffff70b98f0 in gtk_main () at ../../../../gtk/gtkmain.c:1328
+    #11 0x0000aaaaaab2138c in main (argc=<optimized out>, argv=<optimized out>) at main.cc:62
+
+GParted is still using Gtk stock icons.  All attempts at re-creating
+this crash by deleting icon files failed because if the desktop theme
+doesn't provide the icons, the Gtk library falls back on using the
+builtin copies of the stock icons instead.  It is unknown how the
+reported managed to trigger this crash.  The only known way to reproduce
+this crash is by changing the GParted source code to request a
+non-existent stock icon.  This change was used:
+    --- a/src/Win_GParted.cc
+    +++ b/src/Win_GParted.cc
+    @@ -743,8 +743,9 @@ void Win_GParted::refresh_combo_devices()
+         {
+             //combo...
+             treerow = *( liststore_devices ->append() ) ;
+    +        static const Gtk::BuiltinStockID UNKNOWN = { ((GtkStock)"unknown") };
+             treerow[ treeview_devices_columns .icon ] =
+    -            Utils::mk_pixbuf(*this, Gtk::Stock::HARDDISK, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+    +            Utils::mk_pixbuf(*this, UNKNOWN, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+             treerow[ treeview_devices_columns .device ] = devices[ i ] .get_path() ;
+             treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length, devices[ i ] .sector_size ) + ")" ;
+
+The bug in Utils::mk_pixbuf() is that render_icon_pixbuf() returned a
+nullptr and was then dereferenced a few lines lower by
+theme_icon->get_width().
+
+Testing this fix with the above crash reproducing change applied results
+in the GUI simply not showing an icon with each device name in the
+device combo box selector.
+
+[1] libgtkmm-3.0-1v5: GParted crashes on Gdk::Pixbuf::get_width()
+    const ()
+    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984953
+
+Closes #282 - Crash due to not checking for failure to load icon
+---
+ src/Utils.cc | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/Utils.cc b/src/Utils.cc
+index 4c4d781a..a9c2e3e1 100644
+--- a/src/Utils.cc
++++ b/src/Utils.cc
+@@ -177,6 +177,8 @@ Glib::RefPtr<Gdk::Pixbuf> Utils::mk_pixbuf(Gtk::Widget& widget,
+                                            Gtk::IconSize icon_size)
+ {
+ 	Glib::RefPtr<Gdk::Pixbuf> theme_icon = widget.render_icon_pixbuf(stock_id, icon_size);
++	if (! theme_icon)
++		return theme_icon;
+ 
+ 	// Ensure icon size
+ 	int width = 0;
+-- 
+GitLab

diff --git a/sys-block/gparted/gparted-1.6.0-r1.ebuild b/sys-block/gparted/gparted-1.6.0-r2.ebuild
similarity index 98%
rename from sys-block/gparted/gparted-1.6.0-r1.ebuild
rename to sys-block/gparted/gparted-1.6.0-r2.ebuild
index e6b5ff10483d..40235e7a54ce 100644
--- a/sys-block/gparted/gparted-1.6.0-r1.ebuild
+++ b/sys-block/gparted/gparted-1.6.0-r2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-04 20:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-21 23:12 [gentoo-commits] repo/gentoo:master commit in: sys-block/gparted/, sys-block/gparted/files/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2025-07-04 20:38 Sam James

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