summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_locl.h
diff options
context:
space:
mode:
authorjsing <>2021-06-19 17:21:40 +0000
committerjsing <>2021-06-19 17:21:40 +0000
commit6afe60e39f7d03240c1f094e1f341b84a8de3f4e (patch)
tree4031b006d4844852d99c4ada4526be15b731c8e0 /src/lib/libssl/ssl_locl.h
parente5895fba963b225b4275079fc84444579ae34b3d (diff)
downloadopenbsd-6afe60e39f7d03240c1f094e1f341b84a8de3f4e.tar.gz
openbsd-6afe60e39f7d03240c1f094e1f341b84a8de3f4e.tar.bz2
openbsd-6afe60e39f7d03240c1f094e1f341b84a8de3f4e.zip
Correctly handle epoch wrapping in dtls1_get_bitmap().
Due to a type bug that has been present in DTLS since the code was first committed in 2005, dtls1_get_bitmap() fails to handle next epoch correctly when the epoch is currently 0xffff (and wraps to zero). For various reasons unknown, the epoch field in the SSL3_RECORD_INTERNAL (formerly SSL3_RECORD) was added as unsigned long (even though the value is an unsigned 16 bit value on the wire, hence cannot exceed 0xffff), however was added to other code as unsigned short. Due to integer promotion, the r_epoch value is incremented by one to become 0x10000, before being cast to an unsigned long and compared to the value pulled from the DTLS record header (which is zero). Strangely 0x10000 != 0, meaning that we drop the DTLS record, instead of queueing it for the next epoch. Fix this issue by using more appropriate types and pulling up the calculation of the next epoch value for improved readability. ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_locl.h')
-rw-r--r--src/lib/libssl/ssl_locl.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 18509438ae..d171ef0984 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.349 2021/06/19 16:52:47 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.350 2021/06/19 17:21:40 jsing 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 *
@@ -886,7 +886,7 @@ typedef struct ssl3_record_internal_st {
886 unsigned int off; /* read/write offset into 'buf' */ 886 unsigned int off; /* read/write offset into 'buf' */
887 unsigned char *data; /* pointer to the record data */ 887 unsigned char *data; /* pointer to the record data */
888 unsigned char *input; /* where the decode bytes are */ 888 unsigned char *input; /* where the decode bytes are */
889 unsigned long epoch; /* epoch number, needed by DTLS1 */ 889 uint16_t epoch; /* epoch number, needed by DTLS1 */
890 unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */ 890 unsigned char seq_num[8]; /* sequence number, needed by DTLS1 */
891} SSL3_RECORD_INTERNAL; 891} SSL3_RECORD_INTERNAL;
892 892