diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-23 19:53:31 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-23 19:53:31 +0000 |
commit | d0e5513c9d23d54a4788f73a2d4e359730e2e9f4 (patch) | |
tree | 0ca8189e67b96c03195193b6b2d060a8aa47b538 /findutils/xargs.c | |
parent | ccfd10bf736720b079ad34d1b353a8e7af42c7c7 (diff) | |
download | busybox-w32-d0e5513c9d23d54a4788f73a2d4e359730e2e9f4.tar.gz busybox-w32-d0e5513c9d23d54a4788f73a2d4e359730e2e9f4.tar.bz2 busybox-w32-d0e5513c9d23d54a4788f73a2d4e359730e2e9f4.zip |
Fix memory problems, and make behavior correct.
git-svn-id: svn://busybox.net/trunk/busybox@1102 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r-- | findutils/xargs.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index 24daf5085..bf68cf768 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -78,13 +78,16 @@ int xargs_main(int argc, char **argv) | |||
78 | /* Now, read in one line at a time from stdin, and run command+args on it */ | 78 | /* Now, read in one line at a time from stdin, and run command+args on it */ |
79 | in_from_stdin = get_line_from_file(stdin); | 79 | in_from_stdin = get_line_from_file(stdin); |
80 | for (;in_from_stdin!=NULL;) { | 80 | for (;in_from_stdin!=NULL;) { |
81 | char *tmp; | ||
81 | len = strlen(in_from_stdin) + len_args_from_cmdline; | 82 | len = strlen(in_from_stdin) + len_args_from_cmdline; |
82 | if ( len > len_cmd_to_be_executed ) { | 83 | len_cmd_to_be_executed+=len+3; |
83 | len_cmd_to_be_executed=len+3; | 84 | cmd_to_be_executed=xrealloc(cmd_to_be_executed, len_cmd_to_be_executed); |
84 | cmd_to_be_executed=xrealloc(cmd_to_be_executed, len_cmd_to_be_executed); | 85 | |
85 | } | 86 | /* Strip out any \n's, so we just get one command to run */ |
87 | while( (tmp = strchr(in_from_stdin, '\n')) != NULL ) | ||
88 | *tmp=' '; | ||
89 | |||
86 | strcat(cmd_to_be_executed, in_from_stdin); | 90 | strcat(cmd_to_be_executed, in_from_stdin); |
87 | strcat(cmd_to_be_executed+strlen(cmd_to_be_executed)-2, " "); | ||
88 | strcat(cmd_to_be_executed, " "); | 91 | strcat(cmd_to_be_executed, " "); |
89 | 92 | ||
90 | free(in_from_stdin); | 93 | free(in_from_stdin); |