[RFC/PATCH] inetd: auto-fill in argv[0]

Mike Frysinger vapier at gentoo.org
Wed Nov 17 10:28:39 UTC 2010


Many programs (like busybox itself) expect argv[0] to be non-NULL.  With
inetd.conf files that skip argv[], inetd execs programs with argc==0.
Then busybox crashes with a NULL pointer deref.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
note: i'm not entirely sure of the standard linux netkit inetd behavior
	to say whether this is worth the effort.  it certainly makes things
	things work better with some inetd.conf files ive come across.

 networking/inetd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/networking/inetd.c b/networking/inetd.c
index ac42c52..07afc43 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -778,6 +778,9 @@ static servtab_t *parse_one_line(void)
 	argc = 0;
 	while ((arg = token[6+argc]) != NULL && argc < MAXARGV)
 		sep->se_argv[argc++] = xstrdup(arg);
+	/* most apps (including busybox) cannot handle argv[0]==NULL */
+	if (argc == 0)
+		sep->se_argv[argc++] = xstrdup(sep->se_program);
 
 	/* catch mixups. "<service> stream udp ..." == wtf */
 	if (sep->se_socktype == SOCK_STREAM) {
-- 
1.7.3.2



More information about the busybox mailing list