summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2026-04-16 07:35:25 +0000
committertb <>2026-04-16 07:35:25 +0000
commit8662e35dbd36d8450a6d4c7188a65c580e4b339f (patch)
tree1d654359e84cbd72a0c4c21e9d9f9ffc5f01ee88 /src/lib
parent8dfa678933bc42faeff1d9406e589c16fac7f60e (diff)
downloadopenbsd-8662e35dbd36d8450a6d4c7188a65c580e4b339f.tar.gz
openbsd-8662e35dbd36d8450a6d4c7188a65c580e4b339f.tar.bz2
openbsd-8662e35dbd36d8450a6d4c7188a65c580e4b339f.zip
libtls: consistently handle allocation failures
Use tls_set_errorx() or tls_error_setx() rather than the versions without x for TLS_ERROR_OUT_OF_MEMORY. ENOMEM adds no further info. From Michael Forney ok bcook
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libtls/tls_ocsp.c4
-rw-r--r--src/lib/libtls/tls_signer.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libtls/tls_ocsp.c b/src/lib/libtls/tls_ocsp.c
index 784d911b7a..b8d855c4c8 100644
--- a/src/lib/libtls/tls_ocsp.c
+++ b/src/lib/libtls/tls_ocsp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_ocsp.c,v 1.28 2026/04/16 07:28:00 tb Exp $ */ 1/* $OpenBSD: tls_ocsp.c,v 1.29 2026/04/16 07:35:25 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Marko Kreen <markokr@gmail.com> 3 * Copyright (c) 2015 Marko Kreen <markokr@gmail.com>
4 * Copyright (c) 2016 Bob Beck <beck@openbsd.org> 4 * Copyright (c) 2016 Bob Beck <beck@openbsd.org>
@@ -85,7 +85,7 @@ tls_ocsp_fill_info(struct tls *ctx, int response_status, int cert_status,
85 ctx->ocsp->ocsp_result = NULL; 85 ctx->ocsp->ocsp_result = NULL;
86 86
87 if ((info = calloc(1, sizeof (struct tls_ocsp_result))) == NULL) { 87 if ((info = calloc(1, sizeof (struct tls_ocsp_result))) == NULL) {
88 tls_set_error(ctx, TLS_ERROR_OUT_OF_MEMORY, "out of memory"); 88 tls_set_errorx(ctx, TLS_ERROR_OUT_OF_MEMORY, "out of memory");
89 return -1; 89 return -1;
90 } 90 }
91 info->response_status = response_status; 91 info->response_status = response_status;
diff --git a/src/lib/libtls/tls_signer.c b/src/lib/libtls/tls_signer.c
index ad80296830..2d6635460e 100644
--- a/src/lib/libtls/tls_signer.c
+++ b/src/lib/libtls/tls_signer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_signer.c,v 1.14 2026/04/16 05:16:48 tb Exp $ */ 1/* $OpenBSD: tls_signer.c,v 1.15 2026/04/16 07:35:25 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2021 Eric Faurot <eric@openbsd.org> 3 * Copyright (c) 2021 Eric Faurot <eric@openbsd.org>
4 * 4 *
@@ -147,7 +147,7 @@ tls_signer_add_keypair_mem(struct tls_signer *signer, const uint8_t *cert,
147 } 147 }
148 148
149 if ((skey = calloc(1, sizeof(*skey))) == NULL) { 149 if ((skey = calloc(1, sizeof(*skey))) == NULL) {
150 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 150 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
151 "out of memory"); 151 "out of memory");
152 goto err; 152 goto err;
153 } 153 }
@@ -233,7 +233,7 @@ tls_sign_rsa(struct tls_signer *signer, struct tls_signer_key *skey,
233 return (-1); 233 return (-1);
234 } 234 }
235 if ((signature = calloc(1, rsa_size)) == NULL) { 235 if ((signature = calloc(1, rsa_size)) == NULL) {
236 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 236 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
237 "out of memory"); 237 "out of memory");
238 return (-1); 238 return (-1);
239 } 239 }
@@ -281,7 +281,7 @@ tls_sign_ecdsa(struct tls_signer *signer, struct tls_signer_key *skey,
281 return (-1); 281 return (-1);
282 } 282 }
283 if ((signature = calloc(1, signature_len)) == NULL) { 283 if ((signature = calloc(1, signature_len)) == NULL) {
284 tls_error_set(&signer->error, TLS_ERROR_OUT_OF_MEMORY, 284 tls_error_setx(&signer->error, TLS_ERROR_OUT_OF_MEMORY,
285 "out of memory"); 285 "out of memory");
286 return (-1); 286 return (-1);
287 } 287 }