From: Matt Caswell Date: Thu, 26 Mar 2015 13:12:24 +0000 (+0000) Subject: Define SEQ_NUM_SIZE X-Git-Tag: OpenSSL_1_1_0-pre1~1389 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e5bf62f716f71e4df6995a07d1fbc4cad82a2637;p=oweals%2Fopenssl.git Define SEQ_NUM_SIZE Replace the hard coded value 8 (the size of the sequence number) with a constant defined in a macro. Reviewed-by: Richard Levitte --- diff --git a/ssl/record/dtls1_bitmap.c b/ssl/record/dtls1_bitmap.c index eef6b246e0..9d2d681fbf 100644 --- a/ssl/record/dtls1_bitmap.c +++ b/ssl/record/dtls1_bitmap.c @@ -209,7 +209,7 @@ void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap) bitmap->map <<= shift, bitmap->map |= 1UL; else bitmap->map = 1UL; - memcpy(bitmap->max_seq_num, seq, 8); + memcpy(bitmap->max_seq_num, seq, SEQ_NUM_SIZE); } else { shift = -cmp; if (shift < sizeof(bitmap->map) * 8) diff --git a/ssl/record/record.h b/ssl/record/record.h index 29fc752e6a..99af914b5b 100644 --- a/ssl/record/record.h +++ b/ssl/record/record.h @@ -127,6 +127,8 @@ typedef struct ssl3_buffer_st { int left; } SSL3_BUFFER; +#define SEQ_NUM_SIZE 8 + typedef struct ssl3_record_st { /* type of record */ /* @@ -166,15 +168,15 @@ typedef struct ssl3_record_st { /* sequence number, needed by DTLS1 */ /* * r - */ unsigned char seq_num[8]; + */ unsigned char seq_num[SEQ_NUM_SIZE]; } SSL3_RECORD; typedef struct dtls1_bitmap_st { - unsigned long map; /* track 32 packets on 32-bit systems and 64 - * - on 64-bit systems */ + /* Track 32 packets on 32-bit systems and 64 - on 64-bit systems */ + unsigned long map; - unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit - * value in big-endian encoding */ + /* Max record number seen so far, 64-bit value in big-endian encoding */ + unsigned char max_seq_num[SEQ_NUM_SIZE]; } DTLS1_BITMAP; typedef struct record_pqueue_st { diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index 8bad125780..cfd8290d33 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -156,7 +156,7 @@ int SSL3_RECORD_setup(SSL3_RECORD *r) void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num) { - memcpy(r->seq_num, seq_num, 8); + memcpy(r->seq_num, seq_num, SEQ_NUM_SIZE); } /*