From: Matt Caswell Date: Mon, 25 May 2015 22:57:41 +0000 (+0100) Subject: Handle unsigned struct timeval members X-Git-Tag: OpenSSL_1_0_2b~48 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e40d7c1f3a31fa614760f7a9b75ae40ece5ff8bd;p=oweals%2Fopenssl.git Handle unsigned struct timeval members The members of struct timeval on OpenVMS are unsigned. The logic for calculating timeouts needs adjusting to deal with this. RT#3862 Reviewed-by: Richard Levitte (cherry picked from commit fc52ac9028b9492fb086ba35a3352ea46e03ecfc) --- diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index ac03a6d04d..dc4479f642 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -303,16 +303,17 @@ static void dgram_adjust_rcv_timeout(BIO *b) /* Calculate time left until timer expires */ memcpy(&timeleft, &(data->next_timeout), sizeof(struct timeval)); - timeleft.tv_sec -= timenow.tv_sec; - timeleft.tv_usec -= timenow.tv_usec; - if (timeleft.tv_usec < 0) { + if (timeleft.tv_usec < timenow.tv_usec) { + timeleft.tv_usec = 1000000 - timenow.tv_usec + timeleft.tv_usec; timeleft.tv_sec--; - timeleft.tv_usec += 1000000; + } else { + timeleft.tv_usec -= timenow.tv_usec; } - - if (timeleft.tv_sec < 0) { + if (timeleft.tv_sec < timenow.tv_sec) { timeleft.tv_sec = 0; timeleft.tv_usec = 1; + } else { + timeleft.tv_sec -= timenow.tv_sec; } /*