summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src/ssl/t1_enc.c
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-08-07 19:46:31 +0000
committermiod <miod@openbsd.org>2014-08-07 19:46:31 +0000
commitffb772b401a7e4d8ff166372a160eb0da562824c (patch)
tree4204be25125390a03429c66abc90c5b245fee015 /lib/libssl/src/ssl/t1_enc.c
parentBump example pubkey filenames to /etc/signify/openbsd-56-base.pub for (diff)
downloadwireguard-openbsd-ffb772b401a7e4d8ff166372a160eb0da562824c.tar.xz
wireguard-openbsd-ffb772b401a7e4d8ff166372a160eb0da562824c.zip
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@
Diffstat (limited to 'lib/libssl/src/ssl/t1_enc.c')
-rw-r--r--lib/libssl/src/ssl/t1_enc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libssl/src/ssl/t1_enc.c b/lib/libssl/src/ssl/t1_enc.c
index e4b54691c69..bec8328269b 100644
--- a/lib/libssl/src/ssl/t1_enc.c
+++ b/lib/libssl/src/ssl/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);
}
}