]> git.kaiwu.me - haproxy.git/commit
[BUG] fix calls to localtime()
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Oct 2007 08:34:16 +0000 (10:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 31 Oct 2007 07:52:05 +0000 (08:52 +0100)
commitc84aa3f824a8b671e3b64fd0bce77345373a9234
tree62f06f5d0b7e007029e903755b2e0e47f2f6d1dc
parentacf7e9bc491e791897907b64cf7e90c0a042bb6f
[BUG] fix calls to localtime()

localtime() was called with pointers to tv_sec, which is time_t on
some platforms and long on others. A problem was encountered on
Sparc64 under OpenBSD where tv_sec is long (64 bits) and time_t is
32 bits. Since this architecture is big-endian, it exhibited the
bug because localtime() always worked with the high part of the
value which is always zero. This problem was identified and debugged
by Thierry Fournier.

The correct solution is to pass the date by value and not by pointer,
through an intermediate function. The use of localtime_r() instead of
localtime() also made it possible to get rid of the first call to
localtime() since it does not need to allocate memory anymore.
(cherry picked from commit fe94460d53439b5425c154c657db698c63de3d62)
include/common/standard.h
src/haproxy.c
src/log.c
src/proto_http.c
tests/test-log.cfg [new file with mode: 0644]