Fix some invalid use of sscanf
authorMatt Caswell <matt@openssl.org>
Wed, 6 Dec 2023 11:51:01 +0000 (11:51 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 12 Dec 2023 16:12:32 +0000 (16:12 +0000)
commit322517d817ecb5c1a3a8b0e7e038fa146857b4d4
tree1e83e2f25e64dbf76797ae1030d99718718af562
parentb83c719ecb884f609ade7ad7f52bd5e09737585b
Fix some invalid use of sscanf

sscanf can return -1 on an empty input string. We need to appropriately
handle such an invalid case.

The instance in OSSL_HTTP_parse_url could cause an uninitialised read of
sizeof(unsigned int) bytes (typically 4). In many cases this uninit read
will immediately fail on the following check (i.e. if the read value
>65535).

If the top 2 bytes of a 4 byte unsigned int are zero then the value will
be <=65535 and the uninitialised value will be returned to the caller and
could represent arbitrary data on the application stack.

The OpenSSL security team has assessed this issue and consider it to be
a bug only (i.e. not a CVE).

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/22961)
apps/errstr.c
crypto/http/http_lib.c