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

ant.v.moryakov at gmail.com ant.v.moryakov at gmail.com
Fri Apr 18 10:21:34 UTC 2025


From: Maks Mishin <maks.mishinFZ at gmail.com>

The `argv[2]` is checked for NULL in applets_tables.c:214 
and then passed to the rename function in applets_tables.c:241 
without checking for NULL.

Undefined behavior may occur when calling the rename function with this argument.

Signed-off-by: Maks Mishin <maks.mishinFZ at gmail.com>
---
 applets/applet_tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index 66ef7e4ac..ccde59921 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -238,7 +238,7 @@ int main(int argc, char **argv)
 		return 1;
 	if (rename(tmp1, argv[1]))
 		return 1;
-	if (rename(tmp2, argv[2]))
+	if (argv[2] && rename(tmp2, argv[2]))
 		return 1;
 	return 0;
 }
-- 
2.43.0


More information about the busybox mailing list