Fix from Larry for glob problems.
authorEric Andersen <andersen@codepoet.org>
Thu, 15 Mar 2001 23:01:19 +0000 (23:01 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 15 Mar 2001 23:01:19 +0000 (23:01 -0000)
 -Erik

lash.c
sh.c
shell/lash.c

diff --git a/lash.c b/lash.c
index a3003abeae6d9e4c06047e7d4c28661d28490703..6fedfe8ddb42d4e0113df3dcb37d7742c7efe038 100644 (file)
--- 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 a3003abeae6d9e4c06047e7d4c28661d28490703..6fedfe8ddb42d4e0113df3dcb37d7742c7efe038 100644 (file)
--- 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;
                                }
index a3003abeae6d9e4c06047e7d4c28661d28490703..6fedfe8ddb42d4e0113df3dcb37d7742c7efe038 100644 (file)
@@ -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;
                                }