]> asedeno.scripts.mit.edu Git - PuTTY.git/commit
Stop using abs(unsigned) in X11 time comparison.
authorSimon Tatham <anakin@pobox.com>
Thu, 27 Aug 2015 17:39:36 +0000 (18:39 +0100)
committerSimon Tatham <anakin@pobox.com>
Thu, 27 Aug 2015 17:44:51 +0000 (18:44 +0100)
commitb8dd15b8ffd6a9ebdbeceb9db3a3507492780e88
tree853ca53a3b278070173e63ffb7bfef5cd4242a28
parent769600b226cadd1bd08a21ac8fec59698592dbb8
Stop using abs(unsigned) in X11 time comparison.

The validation end of XDM-AUTHORIZATION-1 needs to check that two
time_t values differ by at most XDM_MAXSKEW, which it was doing by
subtracting them and passing the result to abs(). This provoked a
warning from OS X's clang, on the reasonable enough basis that the
value passed to abs was unsigned.

Fixed by using the (well defined) unsigned arithmetic wraparound: to
check that the mathematical difference of two unsigned numbers is in
the interval [-k,+k], compute their difference _plus k_ as an
unsigned, and check the result is in the interval [0,2k] by doing an
unsigned comparison against 2k.
doc/udp.but
x11fwd.c