ssl_cipher_process_rulestr: don't read outside rule_str buffer
authorTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 24 Oct 2022 14:00:48 +0000 (08:00 -0600)
committerTomas Mraz <tomas@openssl.org>
Wed, 26 Oct 2022 10:46:53 +0000 (12:46 +0200)
If rule_str ended in a "-", "l" was incremented one byte past the
end of the buffer.  This resulted in an out-of-bounds read when "l"
is dereferenced at the end of the loop.  It is safest to just return
early in this case since the condition occurs inside a nested loop.

CLA: trivial

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19166)

ssl/ssl_ciph.c

index 2ffad7008cb0c6e696e51f65b951dabc173b47dd..48aad6342bdfa4ec9a2db57ca258e93c6d96b5ca 100644 (file)
@@ -1062,9 +1062,7 @@ static int ssl_cipher_process_rulestr(const char *rule_str,
                  * alphanumeric, so we call this an error.
                  */
                 ERR_raise(ERR_LIB_SSL, SSL_R_INVALID_COMMAND);
-                retval = found = 0;
-                l++;
-                break;
+                return 0;
             }
 
             if (rule == CIPHER_SPECIAL) {