httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apachen/src/main util_snprintf.c
Date Tue, 23 Dec 1997 20:36:20 GMT
dgaudet     97/12/23 12:36:19

  Modified:    .        STATUS
               src      CHANGES
               src/main util_snprintf.c
  Log:
  Fix ap_snprintf to do something reasonable when len == 0.  When len == 0 it
  now returns 0 without writing anything.  Previously it would behave like
  sprintf().
  
  Reviewed by:	Jim Jagielski, Ken Coar
  
  Revision  Changes    Path
  1.21      +1 -4      apachen/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /export/home/cvs/apachen/STATUS,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- STATUS	1997/12/23 20:33:38	1.20
  +++ STATUS	1997/12/23 20:36:15	1.21
  @@ -51,12 +51,9 @@
       * Dean's [PATCH] two bugs in mod_autoindex
       * Igor Tatarinov's Re: A tiny correction and a question on writev_it_all
       * Dean's [PATCH] more useful warning message for fcntl() lock failure
  +    * Dean's [PATCH] ap_snprintf should be more sane (fwd)
   
   Available:
  -
  -    * Dean's [PATCH] ap_snprintf should be more sane (fwd)
  -	<Pine.LNX.3.95dg3.971222173805.697D-100000@twinlark.arctic.org>
  -	Status: Dean +1, Jim +1, Ken +1
   
       * Dean's [PATCH] Re: [BUGFIXES] Wrong GID for PID file and UMASK for logs
   	<Pine.LNX.3.95dg3.971216000231.213J-100000@twinlark.arctic.org>
  
  
  
  1.539     +4 -0      apachen/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/CHANGES,v
  retrieving revision 1.538
  retrieving revision 1.539
  diff -u -r1.538 -r1.539
  --- CHANGES	1997/12/23 20:33:40	1.538
  +++ CHANGES	1997/12/23 20:36:17	1.539
  @@ -1,4 +1,8 @@
   Changes with Apache 1.3b4
  +
  +  *) ap_snprintf() with a len of 0 behaved like sprintf().  This is not
  +     useful, and isn't what the standards require.  Now it returns 0
  +     and writes nothing.  [Dean Gaudet]
     
     *) When an error occurs in fcntl() locking suggest the user look up
        the docs for LockFile.  [Dean Gaudet]
  
  
  
  1.11      +11 -10    apachen/src/main/util_snprintf.c
  
  Index: util_snprintf.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_snprintf.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- util_snprintf.c	1997/10/22 20:29:54	1.10
  +++ util_snprintf.c	1997/12/23 20:36:19	1.11
  @@ -903,20 +903,15 @@
       buffy od;
       int cc;
   
  -    /*
  -     * First initialize the descriptor
  -     * Notice that if no length is given, we initialize buf_end to the
  -     * highest possible address.
  -     */
  -    od.buf_end = len ? &buf[len] : (char *) ~0;
  +    /* save 1 byte for nul terminator, we assume len > 0 */
  +    od.buf_end = &buf[len - 1];
       od.nextb = buf;
   
       /*
        * Do the conversion
        */
       cc = format_converter(&od, format, ap);
  -    if (len == 0 || od.nextb <= od.buf_end)
  -	*(od.nextb) = '\0';
  +    *(od.nextb) = '\0';
       if (ccp)
   	*ccp = cc;
   }
  @@ -927,8 +922,11 @@
       int cc;
       va_list ap;
   
  +    if (len == 0)
  +	return 0;
  +
       va_start(ap, format);
  -    strx_printv(&cc, buf, (len - 1), format, ap);
  +    strx_printv(&cc, buf, len, format, ap);
       va_end(ap);
       return (cc);
   }
  @@ -939,7 +937,10 @@
   {
       int cc;
   
  -    strx_printv(&cc, buf, (len - 1), format, ap);
  +    if (len == 0)
  +	return 0;
  +
  +    strx_printv(&cc, buf, len, format, ap);
       return (cc);
   }
   
  
  
  

Mime
View raw message