2 --- clientserver.c 5 Jun 2004 19:59:03 -0000 1.123
3 +++ clientserver.c 5 Jun 2004 20:38:15 -0000
4 @@ -207,7 +207,8 @@ int start_inband_exchange(char *user, ch
5 static int rsync_module(int f_in, int f_out, int i)
8 - char *argv[MAX_ARGS];
12 char line[MAXPATHLEN];
13 uid_t uid = (uid_t)-2; /* canonically "nobody" */
14 @@ -385,6 +386,9 @@ static int rsync_module(int f_in, int f_
16 io_printf(f_out, "@RSYNCD: OK\n");
19 + if (!(argv = new_array(char *, maxargs)))
20 + out_of_memory("rsync_module");
21 argv[argc++] = "rsyncd";
24 @@ -396,23 +400,25 @@ static int rsync_module(int f_in, int f_
28 + if (argc == maxargs) {
29 + maxargs += MAX_ARGS;
30 + if (!(argv = realloc_array(argv, char *, maxargs)))
31 + out_of_memory("rsync_module");
33 if (!(argv[argc] = strdup(p)))
35 + out_of_memory("rsync_module");
38 if (start_glob == 1) {
42 - glob_expand(name, argv, &argc, MAX_ARGS);
43 + glob_expand(name, &argv, &argc, &maxargs);
47 if (strcmp(line, ".") == 0)
50 - if (argc == MAX_ARGS)
56 --- proto.h 5 Jun 2004 20:28:09 -0000 1.195
57 +++ proto.h 5 Jun 2004 20:38:15 -0000
58 @@ -254,7 +254,7 @@ void kill_all(int sig);
59 int name_to_uid(char *name, uid_t *uid);
60 int name_to_gid(char *name, gid_t *gid);
61 int lock_range(int fd, int offset, int len);
62 -void glob_expand(char *base1, char **argv, int *argc_ptr, int maxargs);
63 +void glob_expand(char *base1, char ***argv_ptr, int *argc_ptr, int *maxargs_ptr);
64 void strlower(char *s);
65 size_t pathjoin(char *dest, size_t destsize, const char *p1, const char *p2);
66 size_t stringjoin(char *dest, size_t destsize, ...);
68 --- util.c 5 Jun 2004 20:26:56 -0000 1.148
69 +++ util.c 5 Jun 2004 20:38:16 -0000
70 @@ -495,12 +495,20 @@ static int exclude_server_path(char *arg
74 -static void glob_expand_one(char *s, char **argv, int *argc_ptr, int maxargs)
75 +static void glob_expand_one(char *s, char ***argv_ptr, int *argc_ptr,
78 + char **argv = *argv_ptr;
80 + int maxargs = *maxargs_ptr;
81 #if !(defined(HAVE_GLOB) && defined(HAVE_GLOB_H))
82 - if (maxargs <= argc)
84 + if (argc == maxargs) {
85 + maxargs += MAX_ARGS;
86 + if (!(argv = realloc_array(argv, char *, maxargs)))
87 + out_of_memory("glob_expand_one");
89 + *maxargs_ptr = maxargs;
93 s = argv[argc++] = strdup(s);
94 @@ -521,12 +529,17 @@ static void glob_expand_one(char *s, cha
95 memset(&globbuf, 0, sizeof globbuf);
96 if (!exclude_server_path(s))
97 glob(s, 0, NULL, &globbuf);
98 + if (MAX((int)globbuf.gl_pathc, 1) > maxargs - argc) {
99 + maxargs += globbuf.gl_pathc + MAX_ARGS;
100 + if (!(argv = realloc_array(argv, char *, maxargs)))
101 + out_of_memory("glob_expand_one");
103 + *maxargs_ptr = maxargs;
105 if (globbuf.gl_pathc == 0)
108 int j = globbuf.gl_pathc;
109 - if (j > maxargs - argc)
110 - j = maxargs - argc;
112 for (i = 0; i < j; i++) {
113 if (!(argv[argc++] = strdup(globbuf.gl_pathv[i])))
114 @@ -539,9 +552,9 @@ static void glob_expand_one(char *s, cha
117 /* This routine is only used in daemon mode. */
118 -void glob_expand(char *base1, char **argv, int *argc_ptr, int maxargs)
119 +void glob_expand(char *base1, char ***argv_ptr, int *argc_ptr, int *maxargs_ptr)
121 - char *s = argv[*argc_ptr];
122 + char *s = (*argv_ptr)[*argc_ptr];
125 int base_len = strlen(base);
126 @@ -562,7 +575,7 @@ void glob_expand(char *base1, char **arg
127 for (q = s; *q; q = p + base_len) {
128 if ((p = strstr(q, base)) != NULL)
129 *p = '\0'; /* split it at this point */
130 - glob_expand_one(q, argv, argc_ptr, maxargs);
131 + glob_expand_one(q, argv_ptr, argc_ptr, maxargs_ptr);