From 42c2ba106a36f62e1c265075da9b41ed9048ff42 Mon Sep 17 00:00:00 2001 From: Doug Hogan Date: Tue, 14 Jul 2015 05:20:47 +0000 Subject: Convert ssl3_get_cipher_by_char to CBS. ok miod@ jsing@ --- lib/libssl/s3_lib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/libssl') diff --git a/lib/libssl/s3_lib.c b/lib/libssl/s3_lib.c index 79f680f527e..c838409bf7a 100644 --- a/lib/libssl/s3_lib.c +++ b/lib/libssl/s3_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_lib.c,v 1.96 2015/05/25 21:35:35 guenther Exp $ */ +/* $OpenBSD: s3_lib.c,v 1.97 2015/07/14 05:20:46 doug Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -155,6 +155,7 @@ #include #include "ssl_locl.h" +#include "bytestring.h" #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers) / sizeof(SSL_CIPHER)) @@ -2532,9 +2533,14 @@ ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) const SSL_CIPHER * ssl3_get_cipher_by_char(const unsigned char *p) { + CBS cipher; uint16_t cipher_value; - n2s(p, cipher_value); + /* We have to assume it is at least 2 bytes due to existing API. */ + CBS_init(&cipher, p, 2); + if (!CBS_get_u16(&cipher, &cipher_value)) + return NULL; + return ssl3_get_cipher_by_value(cipher_value); } -- cgit v1.2.3