From 6bf4ca08404708bd83a56b1982aa6823d2f605f1 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sat, 16 May 2009 16:18:45 +0000 Subject: [PATCH] Update from 1.0.0-stable. --- crypto/pqueue/pqueue.c | 14 ++++++++++++++ crypto/pqueue/pqueue.h | 1 + ssl/d1_pkt.c | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/crypto/pqueue/pqueue.c b/crypto/pqueue/pqueue.c index 5cc18527f8..6c89f06fb1 100644 --- a/crypto/pqueue/pqueue.c +++ b/crypto/pqueue/pqueue.c @@ -234,3 +234,17 @@ pqueue_next(pitem **item) return ret; } + +int +pqueue_size(pqueue_s *pq) +{ + pitem *item = pq->items; + int count = 0; + + while(item != NULL) + { + count++; + item = item->next; + } + return count; +} diff --git a/crypto/pqueue/pqueue.h b/crypto/pqueue/pqueue.h index 02386d130e..16c4072681 100644 --- a/crypto/pqueue/pqueue.h +++ b/crypto/pqueue/pqueue.h @@ -91,5 +91,6 @@ pitem *pqueue_iterator(pqueue pq); pitem *pqueue_next(piterator *iter); void pqueue_print(pqueue pq); +int pqueue_size(pqueue pq); #endif /* ! HEADER_PQUEUE_H */ diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index 3906019023..ec7752d93a 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c @@ -167,6 +167,10 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, PQ_64BIT priority) DTLS1_RECORD_DATA *rdata; pitem *item; + /* Limit the size of the queue to prevent DOS attacks */ + if (pqueue_size(queue->q) >= 100) + return 0; + rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA)); item = pitem_new(priority, rdata); if (rdata == NULL || item == NULL) -- 2.40.0