提交 4f2011d9 编写于 作者: A Adam Langley 提交者: Matt Caswell

Remove some duplicate DTLS code.

In a couple of functions, a sequence number would be calculated twice.

Additionally, in |dtls1_process_out_of_seq_message|, we know that
|frag_len| <= |msg_hdr->msg_len| so the later tests for |frag_len <
msg_hdr->msg_len| can be more clearly written as |frag_len !=
msg_hdr->msg_len|, since that's the only remaining case.
Reviewed-by: NMatt Caswell <matt@openssl.org>
Reviewed-by: NEmilia Käsper <emilia@openssl.org>
上级 f6663338
...@@ -604,7 +604,7 @@ static unsigned long dtls1_max_handshake_message_len(const SSL *s) ...@@ -604,7 +604,7 @@ static unsigned long dtls1_max_handshake_message_len(const SSL *s)
} }
static int static int
dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok) dtls1_reassemble_fragment(SSL *s, const struct hm_header_st* msg_hdr, int *ok)
{ {
hm_fragment *frag = NULL; hm_fragment *frag = NULL;
pitem *item = NULL; pitem *item = NULL;
...@@ -687,10 +687,6 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok) ...@@ -687,10 +687,6 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
if (item == NULL) if (item == NULL)
{ {
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char)(msg_hdr->seq>>8);
seq64be[7] = (unsigned char)(msg_hdr->seq);
item = pitem_new(seq64be, frag); item = pitem_new(seq64be, frag);
if (item == NULL) if (item == NULL)
{ {
...@@ -716,7 +712,7 @@ err: ...@@ -716,7 +712,7 @@ err:
static int static int
dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st* msg_hdr, int *ok)
{ {
int i=-1; int i=-1;
hm_fragment *frag = NULL; hm_fragment *frag = NULL;
...@@ -736,7 +732,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) ...@@ -736,7 +732,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
/* If we already have an entry and this one is a fragment, /* If we already have an entry and this one is a fragment,
* don't discard it and rather try to reassemble it. * don't discard it and rather try to reassemble it.
*/ */
if (item != NULL && frag_len < msg_hdr->msg_len) if (item != NULL && frag_len != msg_hdr->msg_len)
item = NULL; item = NULL;
/* Discard the message if sequence number was already there, is /* Discard the message if sequence number was already there, is
...@@ -761,7 +757,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) ...@@ -761,7 +757,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
} }
else else
{ {
if (frag_len < msg_hdr->msg_len) if (frag_len != msg_hdr->msg_len)
return dtls1_reassemble_fragment(s, msg_hdr, ok); return dtls1_reassemble_fragment(s, msg_hdr, ok);
if (frag_len > dtls1_max_handshake_message_len(s)) if (frag_len > dtls1_max_handshake_message_len(s))
...@@ -784,10 +780,6 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) ...@@ -784,10 +780,6 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
goto err; goto err;
} }
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char)(msg_hdr->seq>>8);
seq64be[7] = (unsigned char)(msg_hdr->seq);
item = pitem_new(seq64be, frag); item = pitem_new(seq64be, frag);
if ( item == NULL) if ( item == NULL)
goto err; goto err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册