521a522
> unsigned long frag_len = frag->msg_header.frag_len;
539c540
< return frag->msg_header.frag_len;
---
> return frag_len;
564c565,574
< if (msg_hdr->seq <= s->d1->handshake_read_seq)
---
> /* Try to find item in queue, to prevent duplicate entries */
> pq_64bit_init(&seq64);
> pq_64bit_assign_word(&seq64, msg_hdr->seq);
> item = pqueue_find(s->d1->buffered_messages, seq64);
> pq_64bit_free(&seq64);
>
> /* Discard the message if sequence number was already there, is
> * too far in the future or the fragment is already in the queue */
> if (msg_hdr->seq <= s->d1->handshake_read_seq ||
> msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL)
578,580c588,592
< frag = dtls1_hm_fragment_new(frag_len);
< if ( frag == NULL)
< goto err;
---
> if (frag_len)
> {
> frag = dtls1_hm_fragment_new(frag_len);
> if ( frag == NULL)
> goto err;
582c594
< memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
---
> memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
584,586c596
< if (frag_len)
< {
< /* read the body of the fragment (header has already been read */
---
> /* read the body of the fragment (header has already been read) */
591d600
< }
593,594c602,603
< pq_64bit_init(&seq64);
< pq_64bit_assign_word(&seq64, msg_hdr->seq);
---
> pq_64bit_init(&seq64);
> pq_64bit_assign_word(&seq64, msg_hdr->seq);
596,599c605,608
< item = pitem_new(seq64, frag);
< pq_64bit_free(&seq64);
< if ( item == NULL)
< goto err;
---
> item = pitem_new(seq64, frag);
> pq_64bit_free(&seq64);
> if ( item == NULL)
> goto err;
601c610,612
< pqueue_insert(s->d1->buffered_messages, item);
---
> pqueue_insert(s->d1->buffered_messages, item);
> }
>
> unsigned long frag_len = frag->msg_header.frag_len;
539c540
< return frag->msg_header.frag_len;
---
> return frag_len;
564c565,574
< if (msg_hdr->seq <= s->d1->handshake_read_seq)
---
> /* Try to find item in queue, to prevent duplicate entries */
> pq_64bit_init(&seq64);
> pq_64bit_assign_word(&seq64, msg_hdr->seq);
> item = pqueue_find(s->d1->buffered_messages, seq64);
> pq_64bit_free(&seq64);
>
> /* Discard the message if sequence number was already there, is
> * too far in the future or the fragment is already in the queue */
> if (msg_hdr->seq <= s->d1->handshake_read_seq ||
> msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL)
578,580c588,592
< frag = dtls1_hm_fragment_new(frag_len);
< if ( frag == NULL)
< goto err;
---
> if (frag_len)
> {
> frag = dtls1_hm_fragment_new(frag_len);
> if ( frag == NULL)
> goto err;
582c594
< memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
---
> memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
584,586c596
< if (frag_len)
< {
< /* read the body of the fragment (header has already been read */
---
> /* read the body of the fragment (header has already been read) */
591d600
< }
593,594c602,603
< pq_64bit_init(&seq64);
< pq_64bit_assign_word(&seq64, msg_hdr->seq);
---
> pq_64bit_init(&seq64);
> pq_64bit_assign_word(&seq64, msg_hdr->seq);
596,599c605,608
< item = pitem_new(seq64, frag);
< pq_64bit_free(&seq64);
< if ( item == NULL)
< goto err;
---
> item = pitem_new(seq64, frag);
> pq_64bit_free(&seq64);
> if ( item == NULL)
> goto err;
601c610,612
< pqueue_insert(s->d1->buffered_messages, item);
---
> pqueue_insert(s->d1->buffered_messages, item);
> }
>