diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-06-07 17:45:14 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-06-07 17:45:14 +0000 |
commit | cde7a9caee8efd9a03476113d02b00bc9145f094 (patch) | |
tree | 8301f2ec0ddd2a3441bfd206b3c6cb15a2b76270 | |
parent | 092337c5842663ed49202f3cf8830d432de5bb57 (diff) |
Simplify various CBS_write_bytes() calls
Now that session_id_length is a size_t, we can pass it directly to
CBS_write_bytes() instead of using a temporary variable.
ok jsing
-rw-r--r-- | lib/libssl/ssl_asn1.c | 7 | ||||
-rw-r--r-- | lib/libssl/ssl_clnt.c | 7 | ||||
-rw-r--r-- | lib/libssl/ssl_sess.c | 6 |
3 files changed, 7 insertions, 13 deletions
diff --git a/lib/libssl/ssl_asn1.c b/lib/libssl/ssl_asn1.c index 86e0663584e..d5138115e54 100644 --- a/lib/libssl/ssl_asn1.c +++ b/lib/libssl/ssl_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_asn1.c,v 1.63 2022/06/07 17:20:26 tb Exp $ */ +/* $OpenBSD: ssl_asn1.c,v 1.64 2022/06/07 17:45:13 tb Exp $ */ /* * Copyright (c) 2016 Joel Sing <jsing@openbsd.org> * @@ -295,11 +295,8 @@ d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length) if (!CBS_get_asn1(&session, &session_id, CBS_ASN1_OCTETSTRING)) goto err; if (!CBS_write_bytes(&session_id, s->session_id, sizeof(s->session_id), - &data_len)) + &s->session_id_length)) goto err; - if (data_len > UINT_MAX) - goto err; - s->session_id_length = (unsigned int)data_len; /* Master key. */ if (!CBS_get_asn1(&session, &master_key, CBS_ASN1_OCTETSTRING)) diff --git a/lib/libssl/ssl_clnt.c b/lib/libssl/ssl_clnt.c index f8a80eea2e7..c509771cc3f 100644 --- a/lib/libssl/ssl_clnt.c +++ b/lib/libssl/ssl_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_clnt.c,v 1.145 2022/06/07 17:39:16 tb Exp $ */ +/* $OpenBSD: ssl_clnt.c,v 1.146 2022/06/07 17:45:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -815,7 +815,6 @@ ssl3_get_server_hello(SSL *s) const SSL_CIPHER *cipher; const SSL_METHOD *method; unsigned long alg_k; - size_t outlen; int al, ret; s->internal->first_packet = 1; @@ -975,9 +974,9 @@ ssl3_get_server_hello(SSL *s) * zero length session identifier. */ if (!CBS_write_bytes(&session_id, s->session->session_id, - sizeof(s->session->session_id), &outlen)) + sizeof(s->session->session_id), + &s->session->session_id_length)) goto err; - s->session->session_id_length = outlen; s->session->ssl_version = s->version; } diff --git a/lib/libssl/ssl_sess.c b/lib/libssl/ssl_sess.c index 969371b1de3..504c4021055 100644 --- a/lib/libssl/ssl_sess.c +++ b/lib/libssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.114 2022/06/07 17:32:53 tb Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.115 2022/06/07 17:45:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -526,7 +526,6 @@ int ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) { SSL_SESSION *sess = NULL; - size_t session_id_len; int alert_desc = SSL_AD_INTERNAL_ERROR, fatal = 0; int ticket_decrypted = 0; @@ -555,11 +554,10 @@ ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) * ticket has been accepted so we copy it into sess. */ if (!CBS_write_bytes(session_id, sess->session_id, - sizeof(sess->session_id), &session_id_len)) { + sizeof(sess->session_id), &sess->session_id_length)) { fatal = 1; goto err; } - sess->session_id_length = (unsigned int)session_id_len; break; default: SSLerror(s, ERR_R_INTERNAL_ERROR); |