apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr/strings apr_cpystrn.c
Date Fri, 05 Apr 2002 19:46:44 GMT
jwoolley    02/04/05 11:46:44

  Modified:    strings  apr_cpystrn.c
  Log:
  Fix a problem where we were walking off the end of the string.
  
  Discovered by: Brad Nicholes
  Submitted by: Cliff Woolley, Jim Jagielski
  
  Revision  Changes    Path
  1.11      +8 -8      apr/strings/apr_cpystrn.c
  
  Index: apr_cpystrn.c
  ===================================================================
  RCS file: /home/cvs/apr/strings/apr_cpystrn.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -d -u -r1.10 -r1.11
  --- apr_cpystrn.c	13 Mar 2002 20:39:26 -0000	1.10
  +++ apr_cpystrn.c	5 Apr 2002 19:46:43 -0000	1.11
  @@ -126,7 +126,7 @@
   {
       const char *cp;
       const char *ct;
  -    int isquoted, numargs = 0;
  +    int isquoted, numargs = 0, argnum;
   
   #define SKIP_WHITESPACE(cp) \
       for ( ; *cp == ' ' || *cp == '\t'; ) { \
  @@ -171,25 +171,25 @@
       while (*ct != '\0') {
           CHECK_QUOTATION(ct, isquoted);
           DETERMINE_NEXTSTRING(ct, isquoted);
  -        ct++;
  +        if (*ct != '\0') {
  +            ct++;
  +        }
           numargs++;
           SKIP_WHITESPACE(ct);
       }
       *argv_out = apr_palloc(token_context, numargs * sizeof(char*));
   
       /*  determine first argument */
  -    numargs = 0;
  -    while (*cp != '\0') {
  +    for (argnum = 0; argnum < (numargs-1); argnum++) {
           CHECK_QUOTATION(cp, isquoted);
           ct = cp;
           DETERMINE_NEXTSTRING(cp, isquoted);
           cp++;
  -        (*argv_out)[numargs] = apr_palloc(token_context, cp - ct);
  -        apr_cpystrn((*argv_out)[numargs], ct, cp - ct);
  -        numargs++;
  +        (*argv_out)[argnum] = apr_palloc(token_context, cp - ct);
  +        apr_cpystrn((*argv_out)[argnum], ct, cp - ct);
           SKIP_WHITESPACE(cp);
       }
  -    (*argv_out)[numargs] = NULL;
  +    (*argv_out)[argnum] = NULL;
   
       return APR_SUCCESS;
   }
  
  
  

Mime
View raw message