]> git.ipfire.org Git - thirdparty/openssl.git/commit
Update hkdf.c to avoid potentially vulnerable code pattern
authorNicky Mouha <nmouha@users.noreply.github.com>
Wed, 17 May 2023 20:46:41 +0000 (16:46 -0400)
committerTomas Mraz <tomas@openssl.org>
Fri, 19 May 2023 10:42:08 +0000 (12:42 +0200)
commit56a51b5a1ecd54eadc80bed4bfe5044a340787c1
treeff5e2b56bfe662438fd6a87cc90ae37af50b53bf
parentd500f04400d0acc83fe5270da860764a7d19deee
Update hkdf.c to avoid potentially vulnerable code pattern

The expression "if (a+b>c) a=c-b" is incorrect if "a+b" overflows.
It should be replaced by "if (a>c-b) a=c-b", which avoids the
potential overflow and is much easier to understand.

This pattern is the root cause of CVE-2022-37454, a buffer overflow
vulnerability in the "official" SHA-3 implementation.

It has been confirmed that the addition in
https://github.com/openssl/openssl/blob/master/providers/implementations/kdfs/hkdf.c#L534
cannot overflow. So this is only a minor change proposal to avoid
a potentially vulnerable code pattern and to improve readability.
More information: https://github.com/github/codeql/pull/12036#issuecomment-1466056959

CLA: trivial

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20990)
providers/implementations/kdfs/hkdf.c