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 | 655a493c39d2b46dbd62ef1f89fc7497375a6cd7 (patch) | |
tree | 407c18c9a22bac239a84a71aeccf8373dd7821ad | |
parent | 474f9307330726c94884d9034636d837d276c2d4 (diff) |
Make sure all error paths in dtls1_buffer_record() invoke SSLErr by
factoring error handling.
ok jsing@
-rw-r--r-- | lib/libssl/d1_pkt.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/libssl/d1_pkt.c b/lib/libssl/d1_pkt.c index 0273db236c5..4e306829bc9 100644 --- a/lib/libssl/d1_pkt.c +++ b/lib/libssl/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); } |