From 1ccd1d69267c785450230e85e831957c5795c17b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 5 May 2025 06:54:27 +0200 Subject: [PATCH 1/4] Bump version for 4.13 release cycle Signed-off-by: Joachim Wiberg --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b5e9bbe2..5e591fd1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Finit], [4.12], [https://github.com/troglobit/finit/issues], +AC_INIT([Finit], [4.13-pre], [https://github.com/troglobit/finit/issues], [finit], [https://troglobit.com/projects/finit/]) AC_CONFIG_AUX_DIR(aux) AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects]) From 4f252858e4fecb343f57616911d5f2308882c353 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 5 May 2025 06:55:08 +0200 Subject: [PATCH 2/4] Enable address sanitizer, credits to @chipitsine Signed-off-by: Joachim Wiberg --- .github/workflows/build.yml | 3 ++- check.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de52e8c1..e6fa09a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,8 @@ jobs: run: | ./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \ --enable-x11-common-plugin --enable-testserv-plugin --with-watchdog \ - --with-keventd + --with-keventd \ + CFLAGS="-fsanitize=address -ggdb" make -j3 clean make -j3 V=1 - name: Install to /tmp diff --git a/check.sh b/check.sh index 9b153629..56c32bb2 100755 --- a/check.sh +++ b/check.sh @@ -3,5 +3,6 @@ make distclean ./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var \ - --enable-x11-common-plugin --with-watchdog --with-keventd + --enable-x11-common-plugin --with-watchdog --with-keventd \ + CFLAGS='-fsanitize=address -ggdb' make -j17 clean check From 8d2cfd69facd517dc60bbada5d04f797bfd635d1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 5 May 2025 07:19:12 +0200 Subject: [PATCH 3/4] initctl: buffer overflow in runlevel string formatting Fix #437 Signed-off-by: Joachim Wiberg --- src/initctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initctl.c b/src/initctl.c index 726fdaa9..f30c836a 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -767,7 +767,7 @@ static int plugins_list(char *arg) */ char *runlevel_string(int currlevel, int levels) { - static char lvl[21]; + static char lvl[32]; int i = INIT_LEVEL; int pos = 1; From 9684127eb73b26d4d63b8f8aca7139059c467a63 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 5 May 2025 07:27:06 +0200 Subject: [PATCH 4/4] initctl: refactor runlevel string composition Related to issue #437 Signed-off-by: Joachim Wiberg --- src/initctl.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/initctl.c b/src/initctl.c index f30c836a..d1698fc4 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -769,25 +769,23 @@ char *runlevel_string(int currlevel, int levels) { static char lvl[32]; int i = INIT_LEVEL; - int pos = 1; - memset(lvl, 0, sizeof(lvl)); - lvl[0] = '['; + strlcpy(lvl, "[", sizeof(lvl)); do { if (ISSET(levels, i)) { - if (!plain && currlevel == i) - pos = strlcat(lvl, "\e[1m", sizeof(lvl)); - - if (i == INIT_LEVEL) - lvl[pos++] = 'S'; - else - lvl[pos++] = '0' + i; + char l[2] = { '0' + i, 0 }; if (!plain && currlevel == i) - pos = strlcat(lvl, "\e[0m", sizeof(lvl)); + strlcat(lvl, "\e[1m", sizeof(lvl)); + + strlcat(lvl, i == INIT_LEVEL ? "S" : l, sizeof(lvl)); + + + if (!plain && currlevel == i) + strlcat(lvl, "\e[0m", sizeof(lvl)); } else { - lvl[pos++] = '-'; + strlcat(lvl, "-", sizeof(lvl)); } /* XXX: ugly hack to get order right: S0123456789 */ @@ -798,8 +796,7 @@ char *runlevel_string(int currlevel, int levels) } while (i < INIT_LEVEL); - lvl[pos++] = ']'; - lvl[pos] = 0; + strlcat(lvl, "]", sizeof(lvl)); return lvl; }