1 After applying this patch and running configure, you MUST run this
6 --- clientserver.c 5 Jun 2004 19:59:03 -0000 1.123
7 +++ clientserver.c 5 Jun 2004 20:38:15 -0000
8 @@ -207,7 +207,8 @@ int start_inband_exchange(char *user, ch
9 static int rsync_module(int f_in, int f_out, int i)
12 - char *argv[MAX_ARGS];
16 char line[MAXPATHLEN];
17 uid_t uid = (uid_t)-2; /* canonically "nobody" */
18 @@ -385,6 +386,9 @@ static int rsync_module(int f_in, int f_
20 io_printf(f_out, "@RSYNCD: OK\n");
23 + if (!(argv = new_array(char *, maxargs)))
24 + out_of_memory("rsync_module");
25 argv[argc++] = "rsyncd";
28 @@ -396,23 +400,25 @@ static int rsync_module(int f_in, int f_
32 + if (argc == maxargs) {
33 + maxargs += MAX_ARGS;
34 + if (!(argv = realloc_array(argv, char *, maxargs)))
35 + out_of_memory("rsync_module");
37 if (!(argv[argc] = strdup(p)))
39 + out_of_memory("rsync_module");
42 if (start_glob == 1) {
46 - glob_expand(name, argv, &argc, MAX_ARGS);
47 + glob_expand(name, &argv, &argc, &maxargs);
51 if (strcmp(line, ".") == 0)
54 - if (argc == MAX_ARGS)
59 --- util.c 5 Jun 2004 20:26:56 -0000 1.148
60 +++ util.c 5 Jun 2004 20:38:16 -0000
61 @@ -495,12 +495,20 @@ static int exclude_server_path(char *arg
65 -static void glob_expand_one(char *s, char **argv, int *argc_ptr, int maxargs)
66 +static void glob_expand_one(char *s, char ***argv_ptr, int *argc_ptr,
69 + char **argv = *argv_ptr;
71 + int maxargs = *maxargs_ptr;
72 #if !(defined(HAVE_GLOB) && defined(HAVE_GLOB_H))
73 - if (maxargs <= argc)
75 + if (argc == maxargs) {
76 + maxargs += MAX_ARGS;
77 + if (!(argv = realloc_array(argv, char *, maxargs)))
78 + out_of_memory("glob_expand_one");
80 + *maxargs_ptr = maxargs;
84 s = argv[argc++] = strdup(s);
85 @@ -521,12 +529,17 @@ static void glob_expand_one(char *s, cha
86 memset(&globbuf, 0, sizeof globbuf);
87 if (!exclude_server_path(s))
88 glob(s, 0, NULL, &globbuf);
89 + if (MAX((int)globbuf.gl_pathc, 1) > maxargs - argc) {
90 + maxargs += globbuf.gl_pathc + MAX_ARGS;
91 + if (!(argv = realloc_array(argv, char *, maxargs)))
92 + out_of_memory("glob_expand_one");
94 + *maxargs_ptr = maxargs;
96 if (globbuf.gl_pathc == 0)
99 int j = globbuf.gl_pathc;
100 - if (j > maxargs - argc)
101 - j = maxargs - argc;
103 for (i = 0; i < j; i++) {
104 if (!(argv[argc++] = strdup(globbuf.gl_pathv[i])))
105 @@ -539,9 +552,9 @@ static void glob_expand_one(char *s, cha
108 /* This routine is only used in daemon mode. */
109 -void glob_expand(char *base1, char **argv, int *argc_ptr, int maxargs)
110 +void glob_expand(char *base1, char ***argv_ptr, int *argc_ptr, int *maxargs_ptr)
112 - char *s = argv[*argc_ptr];
113 + char *s = (*argv_ptr)[*argc_ptr];
116 int base_len = strlen(base);
117 @@ -562,7 +575,7 @@ void glob_expand(char *base1, char **arg
118 for (q = s; *q; q = p + base_len) {
119 if ((p = strstr(q, base)) != NULL)
120 *p = '\0'; /* split it at this point */
121 - glob_expand_one(q, argv, argc_ptr, maxargs);
122 + glob_expand_one(q, argv_ptr, argc_ptr, maxargs_ptr);