From ab70ce9ecea8423d88604836b9841e371c6374b2 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Mon, 26 May 2014 17:06:22 +0000 Subject: Make sure all error paths in dtls1_buffer_record() invoke SSLErr by factoring error handling. ok jsing@ --- lib/libssl/src/ssl/d1_pkt.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/lib/libssl/src/ssl/d1_pkt.c b/lib/libssl/src/ssl/d1_pkt.c index 0273db236c5..4e306829bc9 100644 --- a/lib/libssl/src/ssl/d1_pkt.c +++ b/lib/libssl/src/ssl/d1_pkt.c @@ -224,15 +224,8 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) rdata = malloc(sizeof(DTLS1_RECORD_DATA)); item = pitem_new(priority, rdata); - if (rdata == NULL || item == NULL) { - if (rdata != NULL) - free(rdata); - if (item != NULL) - pitem_free(item); - - SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR); - return (0); - } + if (rdata == NULL || item == NULL) + goto err; rdata->packet = s->packet; rdata->packet_length = s->packet_length; @@ -254,21 +247,20 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) memset(&(s->s3->rbuf), 0, sizeof(SSL3_BUFFER)); memset(&(s->s3->rrec), 0, sizeof(SSL3_RECORD)); - if (!ssl3_setup_buffers(s)) { - SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR); - free(rdata); - pitem_free(item); - return (0); - } + if (!ssl3_setup_buffers(s)) + goto err; /* insert should not fail, since duplicates are dropped */ - if (pqueue_insert(queue->q, item) == NULL) { - free(rdata); - pitem_free(item); - return (0); - } + if (pqueue_insert(queue->q, item) == NULL) + goto err; return (1); + +err: + SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR); + free(rdata); + pitem_free(item); + return (0); } -- cgit v1.2.3