diff options
| author | John Vogel <jvogel@stygian.me> | 2025-02-01 18:07:06 -0500 |
|---|---|---|
| committer | John Vogel <jvogel@stygian.me> | 2025-02-01 18:07:06 -0500 |
| commit | 473821331574b6d292e5e9b381025371f8df7af2 (patch) | |
| tree | a8f77083231d6e052cc951e99fd0653005dc19a0 | |
| parent | c6f27c7035b185bac7256a329a620b8f9ea72227 (diff) | |
| download | forked-aports-473821331574b6d292e5e9b381025371f8df7af2.tar.gz | |
local/bspwm: add some fixes
Upstream PR's 1480 and 1504 (issue 1503), add patches.
1480 revamps signal handling and adds needed include.
1504 fixes null ptr deref.
| -rw-r--r-- | bspwm/0001-Revamp-signal-handling.patch | 106 | ||||
| -rw-r--r-- | bspwm/0002-Add-missing-include-signal.h.patch | 24 | ||||
| -rw-r--r-- | bspwm/0003-Fix-segfault-caused-by-non-null-terminated-string.patch | 29 | ||||
| -rw-r--r-- | bspwm/APKBUILD | 21 |
4 files changed, 174 insertions, 6 deletions
diff --git a/bspwm/0001-Revamp-signal-handling.patch b/bspwm/0001-Revamp-signal-handling.patch new file mode 100644 index 0000000..6399b39 --- /dev/null +++ b/bspwm/0001-Revamp-signal-handling.patch @@ -0,0 +1,106 @@ +From 7fbc56a7be07d25d38aab5c300bed433ec6b1f58 Mon Sep 17 00:00:00 2001 +From: James Cook <falsifian@falsifian.org> +Date: Fri, 12 Jan 2024 01:02:53 +0000 +Subject: [PATCH 1/3] Revamp signal handling. + +- Change from signal to sigaction, which is more portable. + +- Install a handler for SIGPIPE instead of ignoring it, to avoid + passing on the ignored status to other programs launched from + bspwm. + +- Use SA_NOCLDWAIT to avoid the need to call waitpid. (NB if waitpid + were called in the handler, it would be a good idea to protect + errno.) + +- Declare the "running" global as volatile sig_atomic_t, as recommended + for values modified from signal handlers. +--- + src/bspwm.c | 29 +++++++++++++++++------------ + src/bspwm.h | 2 +- + 2 files changed, 18 insertions(+), 13 deletions(-) + +diff --git a/src/bspwm.c b/src/bspwm.c +index 4619a0c..f1d1e6c 100644 +--- a/src/bspwm.c ++++ b/src/bspwm.c +@@ -27,7 +27,6 @@ + #include <sys/stat.h> + #include <sys/types.h> + #include <sys/time.h> +-#include <sys/wait.h> + #include <sys/socket.h> + #include <sys/un.h> + #include <fcntl.h> +@@ -87,7 +86,7 @@ bool auto_raise; + bool sticky_still; + bool hide_sticky; + bool record_history; +-bool running; ++volatile sig_atomic_t running; + bool restart; + bool randr; + +@@ -104,6 +103,7 @@ int main(int argc, char *argv[]) + xcb_generic_event_t *event; + char *end; + int opt; ++ struct sigaction sigact; + + while ((opt = getopt(argc, argv, "hvc:s:o:")) != -1) { + switch (opt) { +@@ -194,11 +194,20 @@ int main(int argc, char *argv[]) + + fcntl(sock_fd, F_SETFD, FD_CLOEXEC | fcntl(sock_fd, F_GETFD)); + +- signal(SIGINT, sig_handler); +- signal(SIGHUP, sig_handler); +- signal(SIGTERM, sig_handler); +- signal(SIGCHLD, sig_handler); +- signal(SIGPIPE, SIG_IGN); ++ sigact.sa_handler = sig_handler; ++ sigemptyset(&sigact.sa_mask); ++ sigact.sa_flags = SA_RESTART; ++ sigaction(SIGINT, &sigact, NULL); ++ sigaction(SIGHUP, &sigact, NULL); ++ sigaction(SIGTERM, &sigact, NULL); ++ /* We avoid using SIG_IGN with SIGPIPE because that would be preserved across ++ exec. */ ++ sigaction(SIGPIPE, &sigact, NULL); ++ ++ sigact.sa_handler = SIG_IGN; ++ sigact.sa_flags = SA_NOCLDWAIT; ++ sigaction(SIGCHLD, &sigact, NULL); ++ + run_config(run_level); + running = true; + +@@ -527,11 +536,7 @@ bool check_connection (xcb_connection_t *dpy) + + void sig_handler(int sig) + { +- if (sig == SIGCHLD) { +- signal(sig, sig_handler); +- while (waitpid(-1, 0, WNOHANG) > 0) +- ; +- } else if (sig == SIGINT || sig == SIGHUP || sig == SIGTERM) { ++ if (sig == SIGINT || sig == SIGHUP || sig == SIGTERM) { + running = false; + } + } +diff --git a/src/bspwm.h b/src/bspwm.h +index 30f972e..9ee3e52 100644 +--- a/src/bspwm.h ++++ b/src/bspwm.h +@@ -84,7 +84,7 @@ extern bool auto_raise; + extern bool sticky_still; + extern bool hide_sticky; + extern bool record_history; +-extern bool running; ++extern volatile sig_atomic_t running; + extern bool restart; + extern bool randr; + +-- +2.47.1 + diff --git a/bspwm/0002-Add-missing-include-signal.h.patch b/bspwm/0002-Add-missing-include-signal.h.patch new file mode 100644 index 0000000..d68e1d8 --- /dev/null +++ b/bspwm/0002-Add-missing-include-signal.h.patch @@ -0,0 +1,24 @@ +From a97c0372a3dffeea69e8f2e3c0ce91e5d67c394a Mon Sep 17 00:00:00 2001 +From: James Cook <falsifian@falsifian.org> +Date: Sat, 13 Jan 2024 03:54:12 +0000 +Subject: [PATCH 2/3] Add missing #include <signal.h>. + +--- + src/bspwm.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/bspwm.h b/src/bspwm.h +index 9ee3e52..bee32d3 100644 +--- a/src/bspwm.h ++++ b/src/bspwm.h +@@ -25,6 +25,7 @@ + #ifndef BSPWM_BSPWM_H + #define BSPWM_BSPWM_H + ++#include <signal.h> + #include "types.h" + + #define WM_NAME "bspwm" +-- +2.47.1 + diff --git a/bspwm/0003-Fix-segfault-caused-by-non-null-terminated-string.patch b/bspwm/0003-Fix-segfault-caused-by-non-null-terminated-string.patch new file mode 100644 index 0000000..edec54e --- /dev/null +++ b/bspwm/0003-Fix-segfault-caused-by-non-null-terminated-string.patch @@ -0,0 +1,29 @@ +From c631b202ab85267759fa875db11e0fa6b0324eaf Mon Sep 17 00:00:00 2001 +From: James Cook <falsifian@falsifian.org> +Date: Fri, 19 Jul 2024 17:20:13 +0000 +Subject: [PATCH 3/3] Fix segfault caused by non-null-terminated string. + +I got the printf %.*s idea from xcb documentation somewhere but now I +can't find it. + +Fixes #1503 +--- + src/rule.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rule.c b/src/rule.c +index b7e55aa..2bf41e8 100644 +--- a/src/rule.c ++++ b/src/rule.c +@@ -307,7 +307,7 @@ void _apply_name(xcb_window_t win, rule_consequence_t *csq) + { + xcb_icccm_get_text_property_reply_t reply; + if (xcb_icccm_get_wm_name_reply(dpy, xcb_icccm_get_wm_name(dpy, win), &reply, NULL) == 1) { +- snprintf(csq->name, sizeof(csq->name), "%s", reply.name); ++ snprintf(csq->name, sizeof(csq->name), "%.*s", reply.name_len, reply.name); + xcb_icccm_get_text_property_reply_wipe(&reply); + } + } +-- +2.47.1 + diff --git a/bspwm/APKBUILD b/bspwm/APKBUILD index bc2abd5..f94af0b 100644 --- a/bspwm/APKBUILD +++ b/bspwm/APKBUILD @@ -1,9 +1,11 @@ # Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net> -# Maintainer: prspkt <prspkt@protonmail.com> +# Contributor: prspkt <prspkt@protonmail.com> +# Maintainer: John Vogel <jvogel@stygian.me> +maintainer="John Vogel <jvogel@stygian.me>" pkgname=bspwm pkgver=0.9.10_git20230829 -pkgrel=0 -_gitrev=af3bd8b4351f4478fe0fe3cfd6c09e44cb108b4b +pkgrel=1 +_commit=af3bd8b4351f4478fe0fe3cfd6c09e44cb108b4b pkgdesc="Tiling window manager based on binary space partitioning" url="https://github.com/baskerville/bspwm" arch="all" @@ -16,8 +18,12 @@ subpackages=" $pkgname-bash-completion $pkgname-fish-completion " -source="https://github.com/baskerville/bspwm/archive/$_gitrev/bspwm-$pkgver.tar.gz" -builddir="$srcdir/bspwm-$_gitrev" +source="bspwm-$_commit.tar.gz::https://github.com/baskerville/bspwm/archive/$_commit.tar.gz + 0001-Revamp-signal-handling.patch + 0002-Add-missing-include-signal.h.patch + 0003-Fix-segfault-caused-by-non-null-terminated-string.patch + " +builddir="$srcdir/bspwm-$_commit" build() { make PREFIX=/usr @@ -28,5 +34,8 @@ package() { } sha512sums=" -151b7401d2d6f911cb910cd94011860a53c46894208b6dc36367f725504d4f4e8f477f7aae9f976ff4a1392f78950938ce2e31b8839b2b9e50fe3a2d4cc7f183 bspwm-0.9.10_git20230829.tar.gz +151b7401d2d6f911cb910cd94011860a53c46894208b6dc36367f725504d4f4e8f477f7aae9f976ff4a1392f78950938ce2e31b8839b2b9e50fe3a2d4cc7f183 bspwm-af3bd8b4351f4478fe0fe3cfd6c09e44cb108b4b.tar.gz +70d3a22511054bdda5a93d3edd15d9eef57bdd0601b2451b6af4344f0d5e71b7709cb9406050faecf9d97e7271901a2ee802c5c6151980726452f1afb4ed4374 0001-Revamp-signal-handling.patch +ecc10012110386ecb16053fd68aee237f0be0c3a9b1951be533bf1699f525ad0ea7e64fed08b7e47b307d4f79a2d3b7716891b933357b5365e5e714c633f0cff 0002-Add-missing-include-signal.h.patch +8a6cc277fdbaa24ee02b088412c1a42ed543fd3930edd7ca6126bd7d12125042d744f107906adfea7b1f195a86ca48df51afa760e2af6b6ed2572e3110ca6ac2 0003-Fix-segfault-caused-by-non-null-terminated-string.patch " |
