summaryrefslogtreecommitdiff
path: root/src/lib/libssl/t1_enc.c
diff options
context:
space:
mode:
authormiod <>2014-08-07 19:46:31 +0000
committermiod <>2014-08-07 19:46:31 +0000
commit15e8f255e119bc9bcc3d331677007d5263431e63 (patch)
treef63319cf5456a29e9fa85ebbd2f5e44de3fb4043 /src/lib/libssl/t1_enc.c
parent4bcdac8281676ec72b23bb5dbfa6716fc392dfc1 (diff)
downloadopenbsd-15e8f255e119bc9bcc3d331677007d5263431e63.tar.gz
openbsd-15e8f255e119bc9bcc3d331677007d5263431e63.tar.bz2
openbsd-15e8f255e119bc9bcc3d331677007d5263431e63.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 'src/lib/libssl/t1_enc.c')
-rw-r--r--src/lib/libssl/t1_enc.c7
1 files changed, 4 insertions, 3 deletions
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 @@
1/* $OpenBSD: t1_enc.c,v 1.67 2014/07/10 10:09:54 jsing Exp $ */ 1/* $OpenBSD: t1_enc.c,v 1.68 2014/08/07 19:46:31 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -319,7 +319,7 @@ tls1_aead_ctx_init(SSL_AEAD_CTX **aead_ctx)
319 319
320static int 320static int
321tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key, 321tls1_change_cipher_state_aead(SSL *s, char is_read, const unsigned char *key,
322 unsigned key_len, const unsigned char *iv, unsigned iv_len) 322 unsigned int key_len, const unsigned char *iv, unsigned int iv_len)
323{ 323{
324 const EVP_AEAD *aead = s->s3->tmp.new_aead; 324 const EVP_AEAD *aead = s->s3->tmp.new_aead;
325 SSL_AEAD_CTX *aead_ctx; 325 SSL_AEAD_CTX *aead_ctx;
@@ -856,6 +856,7 @@ tls1_enc(SSL *s, int send)
856 rec->length += pad; 856 rec->length += pad;
857 } 857 }
858 } else if ((bs != 1) && send) { 858 } else if ((bs != 1) && send) {
859 /* XXX divide by zero if bs == 0 (should not happen) */
859 i = bs - ((int)l % bs); 860 i = bs - ((int)l % bs);
860 861
861 /* Add weird padding of upto 256 bytes */ 862 /* Add weird padding of upto 256 bytes */
@@ -1120,7 +1121,7 @@ tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen,
1120 currentvalpos++; 1121 currentvalpos++;
1121 val[currentvalpos] = contextlen & 0xff; 1122 val[currentvalpos] = contextlen & 0xff;
1122 currentvalpos++; 1123 currentvalpos++;
1123 if ((contextlen > 0) || (context != NULL)) { 1124 if (contextlen != 0 && context != NULL) {
1124 memcpy(val + currentvalpos, context, contextlen); 1125 memcpy(val + currentvalpos, context, contextlen);
1125 } 1126 }
1126 } 1127 }