stoddard 99/10/12 07:09:13
Modified: src/lib/apr/lib apr_cpystrn.c
Log:
Fix bug in ap_tokenize_to_argv.
Revision Changes Path
1.5 +16 -3 apache-2.0/src/lib/apr/lib/apr_cpystrn.c
Index: apr_cpystrn.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_cpystrn.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_cpystrn.c 1999/10/11 14:20:40 1.4
+++ apr_cpystrn.c 1999/10/12 14:09:10 1.5
@@ -136,6 +136,10 @@
cp++; \
}
+/* DETERMINE_NEXTSTRING:
+ * At exit, cp will point to one of the following: NULL, SPACE, TAB or
QUOTE.
+ * NULL implies the argument string has been fully traversed.
+ */
#define DETERMINE_NEXTSTRING(cp,isquoted) \
for ( ; *cp != '\0'; cp++) { \
if ( (isquoted && (*cp == ' ' || *cp == '\t')) \
@@ -175,9 +179,18 @@
CHECK_QUOTATION(cp, isquoted);
tmpCnt = cp;
DETERMINE_NEXTSTRING(cp, isquoted);
- *cp++ = '\0';
- (*argv_out)[numargs] = ap_pstrdup(token_context, tmpCnt);
-
+ if (*cp == '\0') {
+ (*argv_out)[numargs] = ap_pstrdup(token_context, tmpCnt);
+ numargs++;
+ (*argv_out)[numargs] = '\0';
+ break;
+ }
+ else {
+ *cp++ = '\0';
+ (*argv_out)[numargs] = ap_pstrdup(token_context, tmpCnt);
+ numargs++;
+ }
+
SKIP_WHITESPACE(cp);
}
*cp++ = '\0';