summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-07-07 17:12:16 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-07-07 17:12:16 +0000
commit827670ae1f81ba5c13ae23fd2a84c59bfbc5dcca (patch)
tree697e4e2f2e351696b1a5f700058bd6442109d170
parentaf2d9d72b6a78b6d8ad6f3c41529af993f038fd4 (diff)
Make CBB_finish() fail if *out_data is not NULL
Contrary to CBS_stow(), CBB_finish() will leak, so ensure we fail if *out_data is populated. Discussed with & ok jsing
-rw-r--r--lib/libssl/bs_cbb.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c
index 95e53861f00..e2f87be4d2e 100644
--- a/lib/libssl/bs_cbb.c
+++ b/lib/libssl/bs_cbb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bs_cbb.c,v 1.27 2022/01/06 14:30:30 jsing Exp $ */
+/* $OpenBSD: bs_cbb.c,v 1.28 2022/07/07 17:12:15 tb Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
@@ -163,6 +163,9 @@ CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len)
*/
return 0;
+ if (out_data != NULL && *out_data != NULL)
+ return 0;
+
if (out_data != NULL)
*out_data = cbb->base->buf;