From 15e8f255e119bc9bcc3d331677007d5263431e63 Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 7 Aug 2014 19:46:31 +0000 Subject: When you expect a function to return a particular value, don't put a comment saying that you expect it to return that value and compare it against zero because it is supposedly faster, for this leads to bugs (especially given the high rate of sloppy cut'n'paste within ssl3 and dtls1 routines in this library). Instead, compare for the exact value it ought to return upon success. ok deraadt@ --- src/lib/libssl/t1_enc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/lib/libssl/t1_enc.c') diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index e4b54691c6..bec8328269 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_enc.c,v 1.67 2014/07/10 10:09:54 jsing Exp $ */ +/* $OpenBSD: t1_enc.c,v 1.68 2014/08/07 19:46:31 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -319,7 +319,7 @@ tls1_aead_ctx_init(SSL_AEAD_CTX **aead_ctx) static int tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key, - unsigned key_len, const unsigned char *iv, unsigned iv_len) + unsigned int key_len, const unsigned char *iv, unsigned int iv_len) { const EVP_AEAD *aead = s->s3->tmp.new_aead; SSL_AEAD_CTX *aead_ctx; @@ -856,6 +856,7 @@ tls1_enc(SSL *s, int send) rec->length += pad; } } else if ((bs != 1) && send) { + /* XXX divide by zero if bs == 0 (should not happen) */ i = bs - ((int)l % bs); /* Add weird padding of upto 256 bytes */ @@ -1120,7 +1121,7 @@ tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, currentvalpos++; val[currentvalpos] = contextlen & 0xff; currentvalpos++; - if ((contextlen > 0) || (context != NULL)) { + if (contextlen != 0 && context != NULL) { memcpy(val + currentvalpos, context, contextlen); } } -- cgit v1.2.3-55-g6feb