[PATCH] editors: fix potential deref-of-null

2025-01-21 Thread Maks Mishin
The libc standard does not define the behavior when passing a NULL value as a pathname value to an open() call, so a NULL check for the fn pointer has been added. Signed-off-by: Maks Mishin --- editors/vi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editors/vi.c b/editors/vi.c inde

[PATCH] networking: fix potential deref-of-null

2025-01-21 Thread Maks Mishin
The initial condition with the OR operator does not guarantee that the pointer ci will be non-zero when dereferencing, for example, in iproute.c:314: `if (ci->rta_expires)`. For fix this, the OR operator is replaced by the AND operator. The trigger was found using the Svace static analyzer. Sig

[PATCH v2 05/27] getty: change BB_EXECLP call to BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes, reduces code duplication by using BB_EXECVP_or_die. Signed-off-by: Nadav Tasher --- loginutils/getty.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/loginutils/getty.c b/loginutils/getty.c index 4581cc9f7..f5ed2c85c 1

[PATCH v2 04/27] adduser: replace BB_EXECLP call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Signed-off-by: Nadav Tasher --- loginutils/adduser.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/loginutils/adduser.c b/loginutils/adduser.c index d3c795afa..d9f682389 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -158,8 +158,12 @@ static void pas

[no subject]

2025-01-21 Thread Nadav Tasher
Hi all! This second revision to this patch series adds the following changes: 1. Add missing header in executable.c (patch 15) 2. Add support for bb_system, a new "system()" wrapper that uses the spawn_and_wait function to make a "system()" like call, which makes all of the functions that use "sys

[PATCH v2 02/27] bootchartd: convert execl calls to BB_EXECVP

2025-01-21 Thread Nadav Tasher
Signed-off-by: Nadav Tasher --- init/bootchartd.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/init/bootchartd.c b/init/bootchartd.c index 0929890a3..0833e0fe4 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c @@ -355,6 +355,7 @@ int bootchartd_mai

[PATCH v2 01/27] BB_EXECVP: replace execv and execvp calls with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Change calls from execv and execvp to BB_EXECVP for more consistency across applets and more control over executed processes. Signed-off-by: Nadav Tasher --- console-tools/reset.c | 2 +- debianutils/start_stop_daemon.c | 2 +- libbb/run_shell.c | 2 +- networking/ftpd.c

[PATCH v2 03/27] halt: convert execlp call to BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes, reduces code duplication using BB_EXECVP_or_die. Signed-off-by: Nadav Tasher --- init/halt.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/init/halt.c b/init/halt.c index 7aea8cfec..5e6d2 100644 --- a/init/ha

[PATCH v2 17/27] tar: replace execlp call with BB_EXECVP, disable xz compression when applets are prefered

2025-01-21 Thread Nadav Tasher
Use BB_EXECVP for better consistency with other applets. Allows for more control over exactly which compressor is used. The xz compressor is disabled when applets are prefered, since the xz applet does not support compression. Signed-off-by: Nadav Tasher --- archival/tar.c | 11 +-- 1 f

[PATCH v2 15/27] BB_EXECVP: make BB_EXECVP do NOEXEC logic and allow it to to force applet execution

2025-01-21 Thread Nadav Tasher
This patch makes BB_EXECVP the gateway to the exec syscall family. When called, it first looks for a matching applet, and executes it directly of indirectly by re-executing the binary. This new behaviour is configurable by the new FEATURE_FORCE_NOEXEC option. When FEATURE_FORCE_APPLETS is enabled

[PATCH v2 18/27] ash: use BB_EXECVPE to execute commands with FEATURE_SH_STANDALONE

2025-01-21 Thread Nadav Tasher
This change makes the standalone shell use the BB_EXECVPE utility. BB_EXECVPE calls BB_EXECVP which has NOEXEC and applets only logic. This allows for better control of the executed processes. Signed-off-by: Nadav Tasher --- shell/ash.c | 61 +++--

[PATCH v2 12/27] runsv: change execl calls to BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes. Signed-off-by: Nadav Tasher --- runit/runsv.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/runit/runsv.c b/runit/runsv.c index 20a445319..27676e0be 100644 --- a/runit/runsv.c +++ b/runit/runsv.c @@ -280,6 +280,7 @@ st

[PATCH v2 14/27] Config.in: FEATURE_PREFER_APPLETS depends on !BUILD_INDIVIDUAL

2025-01-21 Thread Nadav Tasher
Having FEATURE_PREFER_APPLETS on while building individual applets seems like a bad idea. Applets would try to execute theirselves with different argument if applets are prefered. Signed-off-by: Nadav Tasher --- Config.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Config.in b/Config.in

[PATCH v2 09/27] svlogd: replace execl call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes. Signed-off-by: Nadav Tasher --- runit/svlogd.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runit/svlogd.c b/runit/svlogd.c index f7576f0fa..9b615a05d 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -393,6 +393,7 @

[PATCH v2 10/27] crond: replace execlp calls with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes. Signed-off-by: Nadav Tasher --- miscutils/crond.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/miscutils/crond.c b/miscutils/crond.c index b3762d327..e3f333edb 100644 --- a/miscutils/crond.c +++ b/mis

[PATCH v2 11/27] ifupdown: replace execle call with BB_EXECVPE

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes. Signed-off-by: Nadav Tasher --- networking/ifupdown.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 9c3640be7..d0832 100644 --- a/networking/ifupdown.c +++ b/networkin

[PATCH v2 08/27] script: replace execl call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes, reduces code duplication by using BB_EXECVP_or_die. Signed-off-by: Nadav Tasher --- util-linux/script.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util-linux/script.c b/util-linux/script.c index 58b844e77..46a038c1

[PATCH v2 16/27] vfork_daemon_rexec: update spawn_and_wait function to use BB_EXECVP

2025-01-21 Thread Nadav Tasher
Using BB_EXECVP ensures consistency with spawn() function, and allows moving NOEXEC support to BB_EXECVP, which makes BB_EXECVP to go-to function for running new processes. Signed-off-by: Nadav Tasher --- libbb/vfork_daemon_rexec.c | 25 + 1 file changed, 13 insertions(+)

[PATCH v2 06/27] conspy: replace execl call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes, reduces code duplication by using BB_EXECVP_or_die. Signed-off-by: Nadav Tasher --- miscutils/conspy.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 21a498d0f..5ad19bbdc 10

[PATCH v2 07/27] crontab: replace BB_EXECLP call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes, reduces code duplication by using BB_EXECVP_or_die. Signed-off-by: Nadav Tasher --- miscutils/crontab.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miscutils/crontab.c b/miscutils/crontab.c index f4d54..840df5d5d

[PATCH v2 13/27] runsvdir: replace execlp call with BB_EXECVP

2025-01-21 Thread Nadav Tasher
Allows for more control over executed processes. Signed-off-by: Nadav Tasher --- runit/runsvdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runit/runsvdir.c b/runit/runsvdir.c index d6629dedd..f08880767 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c @@ -119,6 +1

[PATCH v2 20/27] dpkg: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- archival/dpkg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archival/dpkg.c b/archival/dpkg.c index 8031956e9..214c49734 100644 --- a/archi

[PATCH v2 22/27] vi: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- editors/vi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/vi.c b/editors/vi.c index 34932f60c..e27b1604f 100644 --- a/editors/vi.c +

[PATCH v2 23/27] bootchartd: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- init/bootchartd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/bootchartd.c b/init/bootchartd.c index 0833e0fe4..a624ed6e6 100644 --- a

[PATCH v2 26/27] watch: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- procps/watch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/procps/watch.c b/procps/watch.c index 05b72723c..00f3158b7 100644 --- a/procps/w

[PATCH v2 25/27] slattach: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- networking/slattach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/slattach.c b/networking/slattach.c index 2f5cd15ab..2a37ee5de

[PATCH v2 19/27] vfork_daemon_rexec: implement bb_system using spawn_and_wait

2025-01-21 Thread Nadav Tasher
Implemented bb_system using spawn_and_wait in conjuction with "sh", to allow bb_system to execute the internal shell when using the FEATURE_PREFER_APPLETS config option. When FEATURE_PREFER_APPLETS is disabled, libc "system()" is used. Signed-off-by: Nadav Tasher --- include/libbb.h

[PATCH v2 21/27] awk: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- editors/awk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/awk.c b/editors/awk.c index 64e752f4b..9bc5e5c6b 100644 --- a/editors/awk

[PATCH v2 24/27] man: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- miscutils/man.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscutils/man.c b/miscutils/man.c index deaf9e5ab..f0033ebde 100644 --- a/miscu

[PATCH v2 27/27] mdev: Use bb_system instead of system

2025-01-21 Thread Nadav Tasher
Allows for execution of the internal shell when the FEATURE_PREFER_APPLETS config option is enabled. Signed-off-by: Nadav Tasher --- util-linux/mdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/mdev.c b/util-linux/mdev.c index e98d46743..bbf1eff1b 100644 --- a