[BusyBox] init patch
rich_wilson at agilent.com
rich_wilson at agilent.com
Thu Jun 27 09:31:03 UTC 2002
I've found that init has a problem with certain commands, at least on ppc.
The failing line for me is:
::respawn:/bin/sh -i -s </dev/ttyS0 >/dev/ttyS0 2>/dev/ttyS0
The presence of redirection on the line causes the problem, and
it ends up executing (I think) "/bin/sh -c exec ", omitting the rest.
I think it occurs because sizeof("exec ") counts the trailing \0.
One could use strlen(), but that might turn into a run-time
computation, instead of compile time. I haven't taken the time to
try various fixes to assess the code size impact.
The following patch (against the latest .tar.bz2) fixes it for me:
--- init.c.orig Thu Jun 27 08:11:19 2002
+++ init.c Thu Jun 27 08:12:15 2002
@@ -582,8 +582,8 @@
cmd[0] = SHELL;
cmd[1] = "-c";
strcpy(buf, "exec ");
- safe_strncpy(buf + sizeof("exec "), a->command,
- sizeof(buf) - sizeof("exec "));
+ safe_strncpy(buf + sizeof("exec ") - 1, a->command,
+ sizeof(buf) - sizeof("exec ") + 1);
cmd[2] = buf;
cmd[3] = NULL;
} else {
I'd like to see this (or an equivalent fix) put into the source!
Rich
Rich Wilson
Agilent Technologies
425-335-2245
rich_wilson at agilent.com
More information about the busybox
mailing list