aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lash.c6
-rw-r--r--sh.c6
-rw-r--r--shell/lash.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/lash.c b/lash.c
index a3003abea..6fedfe8dd 100644
--- a/lash.c
+++ b/lash.c
@@ -1050,10 +1050,14 @@ static int expand_arguments(char *command)
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
length=strlen(expand_result.gl_pathv[i]);
- if (BUFSIZ-total_length-length <= 0) {
+ if (total_length+length+1 >= BUFSIZ) {
error_msg(out_of_space);
return FALSE;
}
+ if (i>0) {
+ strcat(command+total_length, " ");
+ total_length+=1;
+ }
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}
diff --git a/sh.c b/sh.c
index a3003abea..6fedfe8dd 100644
--- a/sh.c
+++ b/sh.c
@@ -1050,10 +1050,14 @@ static int expand_arguments(char *command)
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
length=strlen(expand_result.gl_pathv[i]);
- if (BUFSIZ-total_length-length <= 0) {
+ if (total_length+length+1 >= BUFSIZ) {
error_msg(out_of_space);
return FALSE;
}
+ if (i>0) {
+ strcat(command+total_length, " ");
+ total_length+=1;
+ }
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}
diff --git a/shell/lash.c b/shell/lash.c
index a3003abea..6fedfe8dd 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1050,10 +1050,14 @@ static int expand_arguments(char *command)
* but don't overflow command which is BUFSIZ in length */
for (i=0; i < expand_result.gl_pathc; i++) {
length=strlen(expand_result.gl_pathv[i]);
- if (BUFSIZ-total_length-length <= 0) {
+ if (total_length+length+1 >= BUFSIZ) {
error_msg(out_of_space);
return FALSE;
}
+ if (i>0) {
+ strcat(command+total_length, " ");
+ total_length+=1;
+ }
strcat(command+total_length, expand_result.gl_pathv[i]);
total_length+=length;
}