[git commit master 1/1] echo: fix SEGV when run with no args

Denys Vlasenko vda.linux at googlemail.com
Tue Feb 15 17:35:54 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=4fdb67cc65e93967448bb28e4cb810ad5648bfea
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/echo.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/coreutils/echo.c b/coreutils/echo.c
index 42c3f9e..72e18c1 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -97,7 +97,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
 		buflen += strlen(arg) + 1;
 		pp++;
 	}
-	out = buffer = xmalloc(buflen);
+	out = buffer = xmalloc(buflen + 1); /* +1 is needed for "no args" case */
 
 	while ((arg = *argv) != NULL) {
 		int c;
-- 
1.7.3.4



More information about the busybox-cvs mailing list