httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: apache-1.3/src/main alloc.c
Date Sat, 07 Sep 2002 22:57:05 GMT
jim         2002/09/07 15:57:05

  Modified:    src      CHANGES
               src/ap   ap_snprintf.c
               src/include ap.h
               src/main alloc.c
  Log:
  Back out incorrect patch for 9932. Use the APR patch.
  
  PR: 9932
  Obtained from: APR Backport
  
  Revision  Changes    Path
  1.1849    +6 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1848
  retrieving revision 1.1849
  diff -u -r1.1848 -r1.1849
  --- CHANGES	5 Sep 2002 14:19:18 -0000	1.1848
  +++ CHANGES	7 Sep 2002 22:57:04 -0000	1.1849
  @@ -1,5 +1,11 @@
   Changes with Apache 1.3.27
   
  +  *) Back out an older patch for PR 9932, which had some incorrect
  +     behavior. Instead, use a backport of the APR fix. This has
  +     the nice effect that ap_snprintf() can now distinguish between
  +     an output which was truncated, and an output which exactly
  +     filled the buffer. [Jim Jagielski]
  +
     *) The cache in mod_proxy was incorrectly updating the Content-Length
        value (to 0) from 304 responses when doing validation. Bugz#10128
        [Paul Terry <paul.terry@gmx.net>, ast@domdv.de, Jim Jagielski]
  
  
  
  1.52      +1 -4      apache-1.3/src/ap/ap_snprintf.c
  
  Index: ap_snprintf.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ap/ap_snprintf.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- ap_snprintf.c	14 Mar 2002 12:08:06 -0000	1.51
  +++ ap_snprintf.c	7 Sep 2002 22:57:05 -0000	1.52
  @@ -1158,10 +1158,7 @@
   	fmt++;
       }
       vbuff->curpos = sp;
  -    if (sp >= bep) {
  -	if (flush_func(vbuff))
  -	    return -1;
  -    }
  +
       return cc;
   }
   
  
  
  
  1.36      +6 -4      apache-1.3/src/include/ap.h
  
  Index: ap.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/include/ap.h,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ap.h	18 Jun 2002 04:19:45 -0000	1.35
  +++ ap.h	7 Sep 2002 22:57:05 -0000	1.36
  @@ -157,11 +157,13 @@
    * Process the format string until the entire string is exhausted, or
    * the buffer fills.  If the buffer fills then stop processing immediately
    * (so no further %n arguments are processed), and return the buffer
  - * length.  In all cases the buffer is NUL terminated.
  + * length.  In all cases the buffer is NUL terminated. The return value
  + * is the number of characters placed in the buffer, excluding the
  + * terminating NUL. All this implies that, at most, (len-1) characters
  + * will be copied over; if the return value is >= len, then truncation
  + * occured.
    *
  - * In no event does ap_snprintf return a negative number.  It's not possible
  - * to distinguish between an output which was truncated, and an output which
  - * exactly filled the buffer.
  + * In no event does ap_snprintf return a negative number.
    */
   API_EXPORT_NONSTD(int) ap_snprintf(char *buf, size_t len, const char *format,...)
   			    __attribute__((format(printf,3,4)));
  
  
  
  1.128     +17 -7     apache-1.3/src/main/alloc.c
  
  Index: alloc.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v
  retrieving revision 1.127
  retrieving revision 1.128
  diff -u -r1.127 -r1.128
  --- alloc.c	13 Mar 2002 21:05:30 -0000	1.127
  +++ alloc.c	7 Sep 2002 22:57:05 -0000	1.128
  @@ -869,36 +869,44 @@
   #endif
   };
   
  +#define AP_PSPRINTF_MIN_SIZE 32  /* Minimum size of allowable avail block */
  +
   static int psprintf_flush(ap_vformatter_buff *vbuff)
   {
       struct psprintf_data *ps = (struct psprintf_data *)vbuff;
   #ifdef ALLOC_USE_MALLOC
  -    int size;
  +    int cur_len, size;
       char *ptr;
   
  -    size = (char *)ps->vbuff.curpos - ps->base;
  -    ptr = realloc(ps->base, 2*size);
  +    cur_len = (char *)ps->vbuff.curpos - ps->base;
  +    size = cur_len << 1;
  +    if (size < AP_PSPRINTF_MIN_SIZE)
  +        size = AP_PSPRINTF_MIN_SIZE;
  +    ptr = realloc(ps->base, size);
       if (ptr == NULL) {
   	fputs("Ouch!  Out of memory!\n", stderr);
   	exit(1);
       }
       ps->base = ptr;
  -    ps->vbuff.curpos = ptr + size;
  -    ps->vbuff.endpos = ptr + 2*size - 1;
  +    ps->vbuff.curpos = ptr + cur_len;
  +    ps->vbuff.endpos = ptr + size - 1;
       return 0;
   #else
       union block_hdr *blok;
       union block_hdr *nblok;
  -    size_t cur_len;
  +    size_t cur_len, size;
       char *strp;
   
       blok = ps->blok;
       strp = ps->vbuff.curpos;
       cur_len = strp - blok->h.first_avail;
  +    size = cur_len << 1;
  +    if (size < AP_PSPRINTF_MIN_SIZE)
  +        size = AP_PSPRINTF_MIN_SIZE;
   
       /* must try another blok */
       (void) ap_acquire_mutex(alloc_mutex);
  -    nblok = new_block(2 * cur_len);
  +    nblok = new_block(size);
       (void) ap_release_mutex(alloc_mutex);
       memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
       ps->vbuff.curpos = nblok->h.first_avail + cur_len;
  @@ -962,6 +970,8 @@
       ps.vbuff.endpos = ps.blok->h.endp - 1;	/* save one for NUL */
       ps.got_a_new_block = 0;
   
  +    if (ps.blok->h.first_avail == ps.blok->h.endp)
  +        psprintf_flush(&ps.vbuff);		/* ensure room for NUL */
       ap_vformatter(psprintf_flush, &ps.vbuff, fmt, ap);
   
       strp = ps.vbuff.curpos;
  
  
  

Mime
View raw message