]> git.ipfire.org Git - thirdparty/openssl.git/commit
fix undefined behavior on 3.1
authorAlexandr Nedvedicky <sashan@openssl.org>
Mon, 19 Aug 2024 11:16:49 +0000 (13:16 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 27 Aug 2024 18:38:15 +0000 (20:38 +0200)
commiteb9790f7ad36d661a00d756b2cb7f6ced7252363
treeeb58703fd75dd90bec89260dfa7c020aac681b5f
parent86f6fdf53a1cf47a54e670a11d8ea44f461eff36
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: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25239)

(cherry picked from commit a85eb03a5ccaccd7b18f979d4dfb5cc76bb61cea)
ssl/ssl_sess.c