httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: httpd-test/flood CHANGES config.h.in
Date Wed, 29 Jan 2003 06:07:50 GMT
jerenkrantz    2003/01/28 22:07:49

  Modified:    flood    CHANGES config.h.in
  Log:
  Fixed Win32 crash resulting from strtoll() macro.
  
  This patch addresses a crash caused by the Win32 implementation
  of the strtoll() macro in config.h, which is generated from
  config.h.in.  This patch fixes config.h.in.  The change will
  affect files using strtoll() on Win32 builds with an "old enough"
  Microsoft Visual C/C++ compiler.
  
  The addition operator ("+") has higher precedence than the conditional
  operator ("a ? b : c").  The portion of the Win32 implementation of the
  strtoll() macro in question is below:
    *(e) = (char*)(p) + ((b) == 10) ? strspn((p), "0123456789") : 0
  The compiler will evaluate the expression like this:
    *(e) = ( (char*)(p) + ((b) == 10) ) ? strspn((p), "0123456789") : 0
  The code was meant to evaluate like this:
    *(e) = (char*)(p) + ( ((b) == 10) ? strspn((p), "0123456789") : 0 )
  The code is effectively pointing "e" to the first nondigit character
  starting at where "p" points to.  Because of the precendence rules,
  the invocation of strtoll() in set_seed() in file flood.c effectively
  compiled to this code:
    *(e) = strspn((p), "0123456789")
  which yields an invalid address.
  
  The above assignment triggers the compiler warning below.
    flood.c(105) : warning C4047: '=' : 'char *' differs in levels of
    indirection from 'const unsigned int '
  The build produces seven occurrences of this warning.  After the
  code fix, those seven occurrences disappear.
  
  When applying this fix, you should rebuild all files to ensure they
  re-evaluate the corrected strtoll() macro from a newly generated
  config.h file.
  
  Reviewed by: Will Rowe
  
  Revision  Changes    Path
  1.42      +3 -0      httpd-test/flood/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-test/flood/CHANGES,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -u -r1.41 -r1.42
  --- CHANGES	1 Aug 2002 22:27:01 -0000	1.41
  +++ CHANGES	29 Jan 2003 06:07:49 -0000	1.42
  @@ -1,5 +1,8 @@
   Changes since 1.0:
   
  +* Fix Win32 crash resulting from strtoll() macro
  +  [Phi-Long Tran <ptran@pobox.com>]
  +
   * Catch some badly formed URLs and exit instead of later crashing.
     [Jacek Prucia <jacek.prucia@7bulls.com>]
   
  
  
  
  1.26      +1 -1      httpd-test/flood/config.h.in
  
  Index: config.h.in
  ===================================================================
  RCS file: /home/cvs/httpd-test/flood/config.h.in,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -u -r1.25 -r1.26
  --- config.h.in	16 Sep 2002 09:55:07 -0000	1.25
  +++ config.h.in	29 Jan 2003 06:07:49 -0000	1.26
  @@ -74,7 +74,7 @@
   #ifdef WIN32
   /* Gross Hack Alert */
   #if _MSC_VER < 1300
  -#define strtoll(p, e, b) ((*(e) = (char*)(p) + ((b) == 10) ? strspn((p), "0123456789")
: 0), _atoi64(p))
  +#define strtoll(p, e, b) ((*(e) = (char*)(p) + (((b) == 10) ? strspn((p), "0123456789")
: 0)), _atoi64(p))
   #else
   #define strtoll(p, e, b) _strtoi64(p, e, b) 
   #endif
  
  
  

Mime
View raw message