ssl_cipher_process_rulestr: don't read outside rule_str buffer
authormillert <millert@openbsd.org>
Wed, 7 Sep 2022 21:34:22 +0000 (21:34 +0000)
committermillert <millert@openbsd.org>
Wed, 7 Sep 2022 21:34:22 +0000 (21:34 +0000)
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.  OK tb@

lib/libssl/ssl_ciph.c

index d304cfe..106a9be 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_ciph.c,v 1.132 2022/09/04 07:55:32 tb Exp $ */
+/* $OpenBSD: ssl_ciph.c,v 1.133 2022/09/07 21:34:22 millert Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -1011,7 +1011,8 @@ ssl_cipher_process_rulestr(const char *rule_str, CIPHER_ORDER **head_p,
                                 */
                                SSLerrorx(SSL_R_INVALID_COMMAND);
                                retval = found = 0;
-                               l++;
+                               if (ch != '\0')
+                                       l++;
                                break;
                        }