Skip to content
Commit a85eb03a authored by Alexandr Nedvedicky's avatar Alexandr Nedvedicky Committed by Tomas Mraz
Browse files

fix undefined behavior on 3.1

(https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=71220

)

OpenSSL 3.2 and later are not affected, because they use
a `safemath` to do integer arithmetics.

This change is specific to 3.1 and 3.0. It changes just
fixes ssl_session_calculate_timeout().

It avoids overflow by testing operands before executint
the operation. It is implemented as follows:

	add(a, b) {
		overflow = MAX_INT - a;
		if (b > overflow)
			result = b - overflow
		else
			result = a + b
	}

Reviewed-by: default avatarPaul Dale <ppzgs1@gmail.com>
Reviewed-by: default avatarTomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25239)
parent 4379b184
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment