From 9b57e2683c5329a908cacd52627dfcb3f67331dc Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 24 Jun 2015 09:44:18 +0000 Subject: [PATCH] Stop using BUF_memdup() within the LibreSSL code base - it is correctly spelt malloc+memcpy, which is what is used in all except two places. ok deraadt@ doug@ --- lib/libssl/bs_cbs.c | 7 ++++--- lib/libssl/s3_clnt.c | 6 +++--- lib/libssl/src/ssl/bs_cbs.c | 7 ++++--- lib/libssl/src/ssl/s3_clnt.c | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/libssl/bs_cbs.c b/lib/libssl/bs_cbs.c index d45353a8902..ea1f0108f61 100644 --- a/lib/libssl/bs_cbs.c +++ b/lib/libssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.16 2015/06/23 05:58:28 doug Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.17 2015/06/24 09:44:18 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -86,10 +86,11 @@ CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) if (cbs->len == 0) return 1; - *out_ptr = BUF_memdup(cbs->data, cbs->len); - if (*out_ptr == NULL) + if ((*out_ptr = malloc(cbs->len)) == NULL) return 0; + memcpy(*out_ptr, cbs->data, cbs->len); + *out_len = cbs->len; return 1; } diff --git a/lib/libssl/s3_clnt.c b/lib/libssl/s3_clnt.c index 0ef17d0067c..cf8b2ec41d0 100644 --- a/lib/libssl/s3_clnt.c +++ b/lib/libssl/s3_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_clnt.c,v 1.113 2015/06/20 18:19:56 doug Exp $ */ +/* $OpenBSD: s3_clnt.c,v 1.114 2015/06/24 09:44:18 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1815,13 +1815,13 @@ ssl3_get_cert_status(SSL *s) goto f_err; } free(s->tlsext_ocsp_resp); - s->tlsext_ocsp_resp = BUF_memdup(p, resplen); - if (!s->tlsext_ocsp_resp) { + if ((s->tlsext_ocsp_resp = malloc(resplen)) == NULL) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } + memcpy(s->tlsext_ocsp_resp, p, resplen); s->tlsext_ocsp_resplen = resplen; if (s->ctx->tlsext_status_cb) { int ret; diff --git a/lib/libssl/src/ssl/bs_cbs.c b/lib/libssl/src/ssl/bs_cbs.c index d45353a8902..ea1f0108f61 100644 --- a/lib/libssl/src/ssl/bs_cbs.c +++ b/lib/libssl/src/ssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.16 2015/06/23 05:58:28 doug Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.17 2015/06/24 09:44:18 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -86,10 +86,11 @@ CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) if (cbs->len == 0) return 1; - *out_ptr = BUF_memdup(cbs->data, cbs->len); - if (*out_ptr == NULL) + if ((*out_ptr = malloc(cbs->len)) == NULL) return 0; + memcpy(*out_ptr, cbs->data, cbs->len); + *out_len = cbs->len; return 1; } diff --git a/lib/libssl/src/ssl/s3_clnt.c b/lib/libssl/src/ssl/s3_clnt.c index 0ef17d0067c..cf8b2ec41d0 100644 --- a/lib/libssl/src/ssl/s3_clnt.c +++ b/lib/libssl/src/ssl/s3_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_clnt.c,v 1.113 2015/06/20 18:19:56 doug Exp $ */ +/* $OpenBSD: s3_clnt.c,v 1.114 2015/06/24 09:44:18 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1815,13 +1815,13 @@ ssl3_get_cert_status(SSL *s) goto f_err; } free(s->tlsext_ocsp_resp); - s->tlsext_ocsp_resp = BUF_memdup(p, resplen); - if (!s->tlsext_ocsp_resp) { + if ((s->tlsext_ocsp_resp = malloc(resplen)) == NULL) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } + memcpy(s->tlsext_ocsp_resp, p, resplen); s->tlsext_ocsp_resplen = resplen; if (s->ctx->tlsext_status_cb) { int ret; -- 2.20.1