Add overflow checks to parse_number/parse_hex/parse_oct
authorNeil Horman <nhorman@openssl.org>
Tue, 28 Nov 2023 18:54:37 +0000 (13:54 -0500)
committerNeil Horman <nhorman@openssl.org>
Thu, 7 Dec 2023 17:21:52 +0000 (12:21 -0500)
commitb861ae7e65d9584e549d8bb24ee5a29ec89dc530
treea9195f0a3768aec57b6c86e923bdfe696efe92ad
parent7cae4263860648f49417f2d5a8a3728329ab109a
Add overflow checks to parse_number/parse_hex/parse_oct

Test the next arithmetic operation to safely determine if adding the
next digit in the passed property string will overflow

Also, noted a bug in the parse_hex code.  When parsing non-digit
characters (i.e. a-f and A-F), we do a tolower conversion (which is
fine), and then subtract 'a' to get the hex value from the ascii (which
is definately wrong).  We should subtract 'W' to convert tolower
converted hex digits in the range a-f to their hex value counterparts

Add tests to test_property_parse_error to ensure overflow checks work

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/22874)

(cherry picked from commit 986c48c4eb26861f25bc68ea252d8f2aad592735)
crypto/property/property_parse.c
test/property_test.c