]> git.kaiwu.me - nginx.git/commit
Fixed signed integer overflows in timer code (ticket #145).
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 6 Apr 2012 23:46:09 +0000 (23:46 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 6 Apr 2012 23:46:09 +0000 (23:46 +0000)
commitbaa239c4870ba2236aeb8c54b892dd25d43d780a
tree17e1e5b2c97e57cfd012e9b14109916cd419d17b
parentbd6d421816f6e317eec512620a51aa0521288405
Fixed signed integer overflows in timer code (ticket #145).

Integer overflow is undefined behaviour in C and this indeed caused
problems on Solaris/SPARC (at least in some cases).  Fix is to
subtract unsigned integers instead, and then cast result to a signed
one, which is implementation-defined behaviour and used to work.

Strictly speaking, we should compare (unsigned) result with the maximum
value of the corresponding signed integer type instead, this will be
defined behaviour.  This will require much more changes though, and
considered to be overkill for now.
src/core/ngx_rbtree.c
src/event/ngx_event_timer.c