[PATCH] flood: Fixed Win32 crash resulting from strtoll() macro.

2003-01-29 Thread ptran
Hi all,

This patch is the first in a series that will produce a running
executable on Win32 platforms with Microsoft Visual C++ 6.0.
My Win32 development environment is Microsoft Windows 2000
Service Pack 3 and MS Visual C++ 6.0 Service Pack 3.  My FLOOD
source was checked out from CVS this morning.

Sincerely,
Phi-Long Tran

Summary:
  * 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.

Index: config.h.in
===
RCS file: /home/cvspublic/httpd-test/flood/config.h.in,v
retrieving revision 1.25
diff -u -r1.25 config.h.in
--- config.h.in 16 Sep 2002 09:55:07 -  1.25
+++ config.h.in 29 Jan 2003 00:20:00 -
@@ -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


Re: [PATCH] flood: Fixed Win32 crash resulting from strtoll() macro.

2003-01-29 Thread William A. Rowe, Jr.
Nice patch, ++1.

At 07:52 PM 1/28/2003, [EMAIL PROTECTED] wrote:
This patch is the first in a series that will produce a running
executable on Win32 platforms with Microsoft Visual C++ 6.0.
My Win32 development environment is Microsoft Windows 2000
Service Pack 3 and MS Visual C++ 6.0 Service Pack 3.  My FLOOD
source was checked out from CVS this morning.

Summary:
  * 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.

Index: config.h.in
===
RCS file: /home/cvspublic/httpd-test/flood/config.h.in,v
retrieving revision 1.25
diff -u -r1.25 config.h.in
--- config.h.in 16 Sep 2002 09:55:07 -  1.25
+++ config.h.in 29 Jan 2003 00:20:00 -
@@ -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




Re: [PATCH] flood: Fixed Win32 crash resulting from strtoll() macro.

2003-01-29 Thread Justin Erenkrantz
--On Tuesday, January 28, 2003 5:52 PM -0800 [EMAIL PROTECTED] wrote:
Hi all,
This patch is the first in a series that will produce a running
executable on Win32 platforms with Microsoft Visual C++ 6.0.
My Win32 development environment is Microsoft Windows 2000
Service Pack 3 and MS Visual C++ 6.0 Service Pack 3.  My FLOOD
source was checked out from CVS this morning.
Applied.  Thanks!
Note: I had to moderate your posts through.  Did you send the posts 
from the same address that you subscribed as?  Regardless, posts from 
[EMAIL PROTECTED] should get through now...  -- justin