diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/bio/bss_mem.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c index 6d0d54db84..0fa6317a2b 100644 --- a/src/lib/libcrypto/bio/bss_mem.c +++ b/src/lib/libcrypto/bio/bss_mem.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bss_mem.c,v 1.22 2023/07/05 21:23:37 beck Exp $ */ | 1 | /* $OpenBSD: bss_mem.c,v 1.27 2025/05/31 11:31:16 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -62,10 +62,10 @@ | |||
62 | #include <string.h> | 62 | #include <string.h> |
63 | 63 | ||
64 | #include <openssl/bio.h> | 64 | #include <openssl/bio.h> |
65 | #include <openssl/err.h> | ||
66 | #include <openssl/buffer.h> | 65 | #include <openssl/buffer.h> |
67 | 66 | ||
68 | #include "bio_local.h" | 67 | #include "bio_local.h" |
68 | #include "err_local.h" | ||
69 | 69 | ||
70 | struct bio_mem { | 70 | struct bio_mem { |
71 | BUF_MEM *buf; | 71 | BUF_MEM *buf; |
@@ -140,6 +140,7 @@ BIO_new_mem_buf(const void *buf, int buf_len) | |||
140 | return NULL; | 140 | return NULL; |
141 | 141 | ||
142 | bm = bio->ptr; | 142 | bm = bio->ptr; |
143 | free(bm->buf->data); | ||
143 | bm->buf->data = (void *)buf; /* Trust in the BIO_FLAGS_MEM_RDONLY flag. */ | 144 | bm->buf->data = (void *)buf; /* Trust in the BIO_FLAGS_MEM_RDONLY flag. */ |
144 | bm->buf->length = buf_len; | 145 | bm->buf->length = buf_len; |
145 | bm->buf->max = buf_len; | 146 | bm->buf->max = buf_len; |
@@ -162,6 +163,12 @@ mem_new(BIO *bio) | |||
162 | free(bm); | 163 | free(bm); |
163 | return 0; | 164 | return 0; |
164 | } | 165 | } |
166 | if (BUF_MEM_grow_clean(bm->buf, 64) != 64) { | ||
167 | BUF_MEM_free(bm->buf); | ||
168 | free(bm); | ||
169 | return 0; | ||
170 | } | ||
171 | bm->buf->length = 0; | ||
165 | 172 | ||
166 | bio->shutdown = 1; | 173 | bio->shutdown = 1; |
167 | bio->init = 1; | 174 | bio->init = 1; |