apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Jones" <oscare...@gmail.com>
Subject PATCH: testdso generating failing dates with uint32 conversion
Date Tue, 11 Dec 2007 20:30:51 GMT
time_t is an int (apr_int64_t on my machine). The lgc routine output is
being casting to apr_uint32_t and then to apr_int64_t = time_t.
Depending on platforms handling of sign extension this may lead to values
for guess > INT_MAX (i.e guess will never be < 0)
This creates a date > the wrap year 2039.  Result is newsecs != secstodate
-> failure

Patch casts the lgc output into an apr_int32_t first and then into time_t =

FYI anyone who knows guts of generating date here's an example of a failure
without this patch:

guess = secstodate = x'fa637fc5' ==  4200824773 (> INT_MAX so the *= -1 has
no effect)
date generated by gm_timestr_822:     Tue, 12 Feb 2103 15:46:13 GMT

after secstodate *= APR_USEC_PER_SEC:
      secstodate x'eeca0bc5bbb40' == 4200824773000000  vs. newsecs hex
x'eec8c9e845b40' == 4200738373000000

PS- i ran newsecs back through gm_timestr_822 to see what it generated and
Mon, 11 Feb 2103 15:46:13 GMT   (month and yr match secstodate results, but
date and day are +/- 1)

View raw message