diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-05-26 17:06:22 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-05-26 17:06:22 +0000 |
commit | ab70ce9ecea8423d88604836b9841e371c6374b2 (patch) | |
tree | b9f0b3b244f51744a734b33caa277472892cd570 | |
parent | d54462bb319a70167c473d6f805b574f764dfa9a (diff) |
Make sure all error paths in dtls1_buffer_record() invoke SSLErr by
factoring error handling.
ok jsing@
-rw-r--r-- | lib/libssl/src/ssl/d1_pkt.c | 32 |
1 files 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); } |