1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

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.
This commit is contained in:
Simon Tatham
2015-08-27 18:39:36 +01:00
parent 769600b226
commit b8dd15b8ff
2 changed files with 5 additions and 2 deletions

View File

@ -46,7 +46,9 @@ on 32-bit architectures \e{or bigger}; so it's safe to assume that
by ANSI C. Similarly, we assume that the execution character
encoding is a superset of the printable characters of ASCII, though
we don't assume the numeric values of control characters,
particularly \cw{'\\n'} and \cw{'\\r'}.)
particularly \cw{'\\n'} and \cw{'\\r'}. Also, the X forwarding code
assumes that \c{time_t} has the Unix format and semantics, i.e. an
integer giving the number of seconds since 1970.)
\H{udp-multi-backend} Multiple backends treated equally