summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_pkt.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/d1_pkt.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/d1_pkt.c')
-rw-r--r--src/lib/libssl/d1_pkt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index c9ffab1f3c..5be89f0955 100644
--- a/src/lib/libssl/d1_pkt.c
+++ b/src/lib/libssl/d1_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_pkt.c,v 1.32 2014/07/10 08:51:14 tedu Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.33 2014/08/07 19:46:31 miod Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -414,10 +414,12 @@ dtls1_process_record(SSL *s)
414 } 414 }
415 415
416 i = s->method->ssl3_enc->mac(s, md, 0 /* not send */); 416 i = s->method->ssl3_enc->mac(s, md, 0 /* not send */);
417 if (i < 0 || mac == NULL || timingsafe_memcmp(md, mac, (size_t)mac_size) != 0) 417 if (i < 0 || mac == NULL ||
418 timingsafe_memcmp(md, mac, (size_t)mac_size) != 0)
418 enc_err = -1; 419 enc_err = -1;
419 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size) 420 if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size)
420 enc_err = -1; 421 enc_err = -1;
422 OPENSSL_cleanse(&md, sizeof md);
421 } 423 }
422 424
423 if (enc_err < 0) { 425 if (enc_err < 0) {