PR: 1931
authorDr. Stephen Henson <steve@openssl.org>
Sat, 16 May 2009 16:22:11 +0000 (16:22 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sat, 16 May 2009 16:22:11 +0000 (16:22 +0000)
Submitted by: Robin Seggelmann <seggelmann@fh-muenster.de>
Approved by: steve@openssl.org

Fix fragment handling memory leak.

ssl/d1_both.c

index 928a005e5377f67ee628b2bfb4278149f9c017e4..ebc03482f0238b81b6385f2394caa3d39726d6fd 100644 (file)
@@ -562,7 +562,16 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
        if ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)
                goto err;
 
-       if (msg_hdr->seq <= s->d1->handshake_read_seq)
+       /* Try to find item in queue, to prevent duplicate entries */
+       memset(seq64be,0,sizeof(seq64be));
+       seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
+       seq64be[7] = (unsigned char) msg_hdr->seq;
+       item = pqueue_find(s->d1->buffered_messages, seq64be);
+       
+       /* 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)
                {
                unsigned char devnull [256];