diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 8b5ef5fff4..9796cf397f 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bio_lib.c,v 1.49 2024/02/16 14:27:43 jsing Exp $ */ | 1 | /* $OpenBSD: bio_lib.c,v 1.50 2024/02/16 14:40:18 jsing 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 | * |
| @@ -134,26 +134,14 @@ LCRYPTO_ALIAS(BIO_get_new_index); | |||
| 134 | BIO * | 134 | BIO * |
| 135 | BIO_new(const BIO_METHOD *method) | 135 | BIO_new(const BIO_METHOD *method) |
| 136 | { | 136 | { |
| 137 | BIO *ret = NULL; | 137 | BIO *bio = NULL; |
| 138 | 138 | ||
| 139 | /* XXX calloc */ | 139 | /* XXX calloc */ |
| 140 | ret = malloc(sizeof(BIO)); | 140 | bio = malloc(sizeof(BIO)); |
| 141 | if (ret == NULL) { | 141 | if (bio == NULL) { |
| 142 | BIOerror(ERR_R_MALLOC_FAILURE); | 142 | BIOerror(ERR_R_MALLOC_FAILURE); |
| 143 | return (NULL); | 143 | return NULL; |
| 144 | } | ||
| 145 | if (!BIO_set(ret, method)) { | ||
| 146 | free(ret); | ||
| 147 | ret = NULL; | ||
| 148 | } | 144 | } |
| 149 | |||
| 150 | return ret; | ||
| 151 | } | ||
| 152 | LCRYPTO_ALIAS(BIO_new); | ||
| 153 | |||
| 154 | int | ||
| 155 | BIO_set(BIO *bio, const BIO_METHOD *method) | ||
| 156 | { | ||
| 157 | bio->method = method; | 145 | bio->method = method; |
| 158 | bio->callback = NULL; | 146 | bio->callback = NULL; |
| 159 | bio->callback_ex = NULL; | 147 | bio->callback_ex = NULL; |
| @@ -174,10 +162,20 @@ BIO_set(BIO *bio, const BIO_METHOD *method) | |||
| 174 | if (!method->create(bio)) { | 162 | if (!method->create(bio)) { |
| 175 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, | 163 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, |
| 176 | &bio->ex_data); | 164 | &bio->ex_data); |
| 177 | return (0); | 165 | free(bio); |
| 166 | return NULL; | ||
| 178 | } | 167 | } |
| 179 | } | 168 | } |
| 180 | return (1); | 169 | |
| 170 | return bio; | ||
| 171 | } | ||
| 172 | LCRYPTO_ALIAS(BIO_new); | ||
| 173 | |||
| 174 | int | ||
| 175 | BIO_set(BIO *bio, const BIO_METHOD *method) | ||
| 176 | { | ||
| 177 | BIOerror(ERR_R_DISABLED); | ||
| 178 | return 0; | ||
| 181 | } | 179 | } |
| 182 | LCRYPTO_ALIAS(BIO_set); | 180 | LCRYPTO_ALIAS(BIO_set); |
| 183 | 181 | ||
| @@ -190,12 +188,12 @@ BIO_free(BIO *bio) | |||
| 190 | return 0; | 188 | return 0; |
| 191 | 189 | ||
| 192 | if (CRYPTO_add(&bio->references, -1, CRYPTO_LOCK_BIO) > 0) | 190 | if (CRYPTO_add(&bio->references, -1, CRYPTO_LOCK_BIO) > 0) |
| 193 | return (1); | 191 | return 1; |
| 194 | 192 | ||
| 195 | if (bio->callback != NULL || bio->callback_ex != NULL) { | 193 | if (bio->callback != NULL || bio->callback_ex != NULL) { |
| 196 | if ((ret = (int)bio_call_callback(bio, BIO_CB_FREE, NULL, 0, 0, | 194 | if ((ret = (int)bio_call_callback(bio, BIO_CB_FREE, NULL, 0, 0, |
| 197 | 0L, 1L, NULL)) <= 0) | 195 | 0L, 1L, NULL)) <= 0) |
| 198 | return (ret); | 196 | return ret; |
| 199 | } | 197 | } |
| 200 | 198 | ||
| 201 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); | 199 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); |
