cURL / Mailing Lists / curl-library / Single Mail

curl-library

win32 bug

From: T. Bharath <TBharath_at_responsenetworks.com>
Date: Tue, 25 Jun 2002 18:28:25 -0400

There is a subtle bug in the highresolution timer calculations used in
windows build which
i had added sometime back. One reason being that i used a % and also
because of a signed
unsigned mismatch leading to an overflow causing some calculations to go
into - if your
machine has been running for a few days.
This also has a potential to cause memory leaks since
ConnectionKillOne uses the connection time to determine the connection
to be closed and during cleanup the calculations may yield a
negative value because of buffer overflow and the cleanup may be skipped
Attached is a patch that fixes that
Whoever has write permission please commit it.

----------------------timeval.c ----------------line 51 -9
----------------------timeval.c-----------------line51 +15
  /**
   ** The earlier time calculations using GetLocalTime
   ** had a time resolution of 10ms.The timeGetTime, part
   ** of multimedia apis offer a better time resolution
   ** of 1ms.Need to link against winmm.lib for this
   **/
- unsigned long Ticks = 0;
- Ticks = timeGetTime();
- tp->tv_sec = Ticks%1000;
- tp->tv_usec = (Ticks - (tp->tv_sec*1000))*1000;

+ unsigned long Ticks = 0;
+ unsigned long Sec =0;
+ unsigned long Usec = 0;
+ Ticks = timeGetTime();
+
+ Sec = Ticks/1000;
+ Usec = (Ticks - (Sec*1000))*1000;
+ tp->tv_sec = Sec;
+ tp->tv_usec = Usec;
 

Sorry Guys

Regards
Bharath

-------------------------------------------------------
This sf.net email is sponsored by: Jabber Inc.
Don't miss the IM event of the season | Special offer for OSDN members!
JabConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn
Received on 2002-06-26