pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/graphics/geeqie graphics/geeqie: Redo patch-ac (UB avo...
details: https://anonhg.NetBSD.org/pkgsrc/rev/ec0120dee541
branches: trunk
changeset: 388553:ec0120dee541
user: gdt <gdt%pkgsrc.org@localhost>
date: Tue Nov 22 14:13:23 2022 +0000
description:
graphics/geeqie: Redo patch-ac (UB avoidance)
Redo patch-ac, which was about avoiding UB from calls that were not
async-signal-safe from a signal handler. Further, the code called
mmap in a way that POSIX says must fail.
Add links to upstream bug report and upstream pull request.
diffstat:
graphics/geeqie/distinfo | 4 +-
graphics/geeqie/patches/patch-ac | 41 ---------------------
graphics/geeqie/patches/patch-src_main.c | 62 ++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 43 deletions(-)
diffs (127 lines):
diff -r 4d3b61284260 -r ec0120dee541 graphics/geeqie/distinfo
--- a/graphics/geeqie/distinfo Tue Nov 22 13:28:57 2022 +0000
+++ b/graphics/geeqie/distinfo Tue Nov 22 14:13:23 2022 +0000
@@ -1,10 +1,10 @@
-$NetBSD: distinfo,v 1.29 2022/11/21 23:55:22 gdt Exp $
+$NetBSD: distinfo,v 1.30 2022/11/22 14:13:23 gdt Exp $
BLAKE2s (geeqie-2.0.1.tar.xz) = 344660eddf23258c87afb4855c616ba24a6eb0562756c15c554bed30e241ae78
SHA512 (geeqie-2.0.1.tar.xz) = cd2251c831c6d4d461d92eee84df08590752ad625e1f50d57e1fb5d0fc6ac16a225584a8217e14bf4f993ba247f7df3296498b27fcc4f5f4c7f25307699aadc5
Size (geeqie-2.0.1.tar.xz) = 1666600 bytes
-SHA1 (patch-ac) = 6cebab3e14ce51c59e70fc902a514d1bbafc3b33
SHA1 (patch-config.h.in) = 301b461a7c3ce8b699f4651363ddf18017eca0df
SHA1 (patch-doc_meson.build) = bfa986b7181355c8f02ffec1af39476a0bc6b491
SHA1 (patch-meson.build) = c6a0ac55b03d3c78619c55f82feebe66ea0a1e6b
SHA1 (patch-meson__options.txt) = e25acfd12c46337e1a992e5629cf82b5fa8f838d
+SHA1 (patch-src_main.c) = 24531eeaf999e26cf0cfd3983a0fbb0eaaaf569f
diff -r 4d3b61284260 -r ec0120dee541 graphics/geeqie/patches/patch-ac
--- a/graphics/geeqie/patches/patch-ac Tue Nov 22 13:28:57 2022 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-$NetBSD: patch-ac,v 1.8 2022/11/21 11:58:47 wiz Exp $
-
-* first hunk
-
-Comment from 2009/07/24:
-
- disable the SIGBUS handler completely -- as implemented it can only
- cause trouble
-
-This is not known to be reported upstream.
-
---- src/main.c.orig 2022-08-12 09:32:26.000000000 +0000
-+++ src/main.c
-@@ -1026,6 +1026,7 @@ void exit_program(void)
- */
- /** @FIXME this probably needs some better ifdefs. Please report any compilation problems */
-
-+#if 0
- #if defined(SIGBUS) && defined(SA_SIGINFO)
- static void sigbus_handler_cb(int UNUSED(signum), siginfo_t *info, void *UNUSED(context))
- {
-@@ -1034,9 +1035,11 @@ static void sigbus_handler_cb(int UNUSED
- mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- }
- #endif
-+#endif /* 0 */
-
- static void setup_sigbus_handler(void)
- {
-+#if 0
- #if defined(SIGBUS) && defined(SA_SIGINFO)
- struct sigaction sigbus_action;
- sigfillset(&sigbus_action.sa_mask);
-@@ -1045,6 +1048,7 @@ static void setup_sigbus_handler(void)
-
- sigaction(SIGBUS, &sigbus_action, NULL);
- #endif
-+#endif /* 0 */
- }
-
- static void set_theme_bg_color()
diff -r 4d3b61284260 -r ec0120dee541 graphics/geeqie/patches/patch-src_main.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/geeqie/patches/patch-src_main.c Tue Nov 22 14:13:23 2022 +0000
@@ -0,0 +1,62 @@
+$NetBSD: patch-src_main.c,v 1.1 2022/11/22 14:13:23 gdt Exp $
+
+Avoid UB in a signal handler, and avoid making an mmap call that POSIX says must fail.
+
+Filed upstream:
+ https://github.com/BestImageViewer/geeqie/issues/1052
+ https://github.com/BestImageViewer/geeqie/pull/1053
+
+--- src/main.c.orig 2022-08-12 09:32:26.000000000 +0000
++++ src/main.c
+@@ -1016,22 +1016,31 @@ void exit_program(void)
+ exit_program_final();
+ }
+
+-/* This code is supposed to handle situation when a file mmaped by image_loader
++/* This code attempts to handle situation when a file mmaped by image_loader
+ * or by exif loader is truncated by some other process.
+- * This is probably not completely correct according to posix, because
+- * mmap is not in the list of calls that can be used safely in signal handler,
+- * but anyway, the handler is called in situation when the application would
+- * crash otherwise.
+- * Ideas for improvement are welcome ;)
++ * This code is incorrect according to POSIX, because:
++ *
++ * mmap is not async-signal-safe and thus may not be called from a signal handler
++ *
++ * mmap must be called with a valid file descriptor. POSIX requires that
++ * a fildes argument of -1 must cause mmap to return EBADF.
++ *
++ * See https://github.com/BestImageViewer/geeqie/issues/1052 for discussion of
++ * an alternative approach.
+ */
+ /** @FIXME this probably needs some better ifdefs. Please report any compilation problems */
+
+ #if defined(SIGBUS) && defined(SA_SIGINFO)
+ static void sigbus_handler_cb(int UNUSED(signum), siginfo_t *info, void *UNUSED(context))
+ {
+- unsigned long pagesize = sysconf(_SC_PAGE_SIZE);
+- DEBUG_1("SIGBUS %p", info->si_addr);
+- mmap((void *)(((unsigned long)info->si_addr / pagesize) * pagesize), pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
++ /*
++ * @FIXME Design and implement a POSIX-acceptable approach,
++ * after first documenting the sitations where SIGBUS occurs.
++ * See https://github.com/BestImageViewer/geeqie/issues/1052 for discussion
++ */
++
++ DEBUG_1("SIGBUS %p NOT HANDLED", info->si_addr);
++ exit(-1);
+ }
+ #endif
+
+@@ -1204,7 +1213,10 @@ gint main(gint argc, gchar *argv[])
+ /* setup random seed for random slideshow */
+ srand(time(NULL));
+
++#if 0
++ /* See later comment; this handler leads to UB. */
+ setup_sigbus_handler();
++#endif
+
+ /* register global notify functions */
+ file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);
Home |
Main Index |
Thread Index |
Old Index