bjh 01/02/13 06:56:13
Modified: threadproc/os2 proc.c
Log:
Don't assume apr_pstrndup will return n bytes of storage. It was recently
optimized to only allocate enough storage for the string if shorter than
n which caused the args to get scrambled.
Revision Changes Path
1.38 +6 -4 apr/threadproc/os2/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- proc.c 2001/02/08 07:45:15 1.37
+++ proc.c 2001/02/13 14:56:09 1.38
@@ -411,16 +411,18 @@
for (i=0; i<numargs; i++)
cmdlen += strlen(newargs[i]) + 3;
- cmdline = apr_pstrndup(cont, newargs[0], cmdlen + 2);
- cmdline_pos = cmdline + strlen(cmdline);
+ cmdline = apr_palloc(cont, cmdlen + 2);
+ cmdline_pos = cmdline;
- for (i=1; i<numargs; i++) {
+ for (i=0; i<numargs; i++) {
const char *a = newargs[i];
if (strpbrk(a, "&|<>\" "))
a = apr_pstrcat(cont, "\"", double_quotes(cont, a), "\"", NULL);
- *(cmdline_pos++) = ' ';
+ if (i)
+ *(cmdline_pos++) = ' ';
+
strcpy(cmdline_pos, a);
cmdline_pos += strlen(cmdline_pos);
}