| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bio/bio_lib.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||
| 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||||||||
| 3 | * | - | ||||||||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||||||||
| 8 | */ | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | #include <stdio.h> | - | ||||||||||||||||||
| 11 | #include <errno.h> | - | ||||||||||||||||||
| 12 | #include <openssl/crypto.h> | - | ||||||||||||||||||
| 13 | #include "bio_lcl.h" | - | ||||||||||||||||||
| 14 | #include "internal/cryptlib.h" | - | ||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | /* | - | ||||||||||||||||||
| 18 | * Helper macro for the callback to determine whether an operator expects a | - | ||||||||||||||||||
| 19 | * len parameter or not | - | ||||||||||||||||||
| 20 | */ | - | ||||||||||||||||||
| 21 | #define HAS_LEN_OPER(o) ((o) == BIO_CB_READ || (o) == BIO_CB_WRITE || \ | - | ||||||||||||||||||
| 22 | (o) == BIO_CB_GETS) | - | ||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | /* | - | ||||||||||||||||||
| 25 | * Helper function to work out whether to call the new style callback or the old | - | ||||||||||||||||||
| 26 | * one, and translate between the two. | - | ||||||||||||||||||
| 27 | * | - | ||||||||||||||||||
| 28 | * This has a long return type for consistency with the old callback. Similarly | - | ||||||||||||||||||
| 29 | * for the "long" used for "inret" | - | ||||||||||||||||||
| 30 | */ | - | ||||||||||||||||||
| 31 | static long bio_call_callback(BIO *b, int oper, const char *argp, size_t len, | - | ||||||||||||||||||
| 32 | int argi, long argl, long inret, size_t *processed) | - | ||||||||||||||||||
| 33 | { | - | ||||||||||||||||||
| 34 | long ret; | - | ||||||||||||||||||
| 35 | int bareoper; | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | if (b->callback_ex != NULL)
| 0-5 | ||||||||||||||||||
| 38 | return b->callback_ex(b, oper, argp, len, argi, argl, inret, processed); never executed: return b->callback_ex(b, oper, argp, len, argi, argl, inret, processed); | 0 | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | /* Strip off any BIO_CB_RETURN flag */ | - | ||||||||||||||||||
| 41 | bareoper = oper & ~BIO_CB_RETURN; | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | /* | - | ||||||||||||||||||
| 44 | * We have an old style callback, so we will have to do nasty casts and | - | ||||||||||||||||||
| 45 | * check for overflows. | - | ||||||||||||||||||
| 46 | */ | - | ||||||||||||||||||
| 47 | if (HAS_LEN_OPER(bareoper)) {
| 0-5 | ||||||||||||||||||
| 48 | /* In this case |len| is set, and should be used instead of |argi| */ | - | ||||||||||||||||||
| 49 | if (len > INT_MAX)
| 0-2 | ||||||||||||||||||
| 50 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | argi = (int)len; | - | ||||||||||||||||||
| 53 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | if (inret && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
| 0-5 | ||||||||||||||||||
| 56 | if (*processed > INT_MAX)
| 0-2 | ||||||||||||||||||
| 57 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 58 | inret = *processed; | - | ||||||||||||||||||
| 59 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | ret = b->callback(b, oper, argp, argi, argl, inret); | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | if (ret >= 0 && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
| 0-5 | ||||||||||||||||||
| 64 | *processed = (size_t)ret; | - | ||||||||||||||||||
| 65 | ret = 1; | - | ||||||||||||||||||
| 66 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | return ret; executed 5 times by 1 test: return ret;Executed by:
| 5 | ||||||||||||||||||
| 69 | } | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | BIO *BIO_new(const BIO_METHOD *method) | - | ||||||||||||||||||
| 72 | { | - | ||||||||||||||||||
| 73 | BIO *bio = OPENSSL_zalloc(sizeof(*bio)); | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | if (bio == NULL) {
| 0-200190 | ||||||||||||||||||
| 76 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 77 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 78 | } | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | bio->method = method; | - | ||||||||||||||||||
| 81 | bio->shutdown = 1; | - | ||||||||||||||||||
| 82 | bio->references = 1; | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data))
| 0-200190 | ||||||||||||||||||
| 85 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | bio->lock = CRYPTO_THREAD_lock_new(); | - | ||||||||||||||||||
| 88 | if (bio->lock == NULL) {
| 0-200190 | ||||||||||||||||||
| 89 | BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 90 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); | - | ||||||||||||||||||
| 91 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | if (method->create != NULL && !method->create(bio)) {
| 0-184588 | ||||||||||||||||||
| 95 | BIOerr(BIO_F_BIO_NEW, ERR_R_INIT_FAIL); | - | ||||||||||||||||||
| 96 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); | - | ||||||||||||||||||
| 97 | CRYPTO_THREAD_lock_free(bio->lock); | - | ||||||||||||||||||
| 98 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 99 | } | - | ||||||||||||||||||
| 100 | if (method->create == NULL)
| 15602-184588 | ||||||||||||||||||
| 101 | bio->init = 1; executed 15602 times by 1 test: bio->init = 1;Executed by:
| 15602 | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | return bio; executed 200190 times by 12 tests: return bio;Executed by:
| 200190 | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | err: | - | ||||||||||||||||||
| 106 | OPENSSL_free(bio); | - | ||||||||||||||||||
| 107 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 108 | } | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | int BIO_free(BIO *a) | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | int ret; | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | if (a == NULL)
| 54311-204985 | ||||||||||||||||||
| 115 | return 0; executed 54311 times by 1 test: return 0;Executed by:
| 54311 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | if (CRYPTO_DOWN_REF(&a->references, &ret, a->lock) <= 0)
| 0-204985 | ||||||||||||||||||
| 118 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | REF_PRINT_COUNT("BIO", a); | - | ||||||||||||||||||
| 121 | if (ret > 0)
| 4795-200190 | ||||||||||||||||||
| 122 | return 1; executed 4795 times by 1 test: return 1;Executed by:
| 4795 | ||||||||||||||||||
| 123 | REF_ASSERT_ISNT(ret < 0); | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | if (a->callback != NULL || a->callback_ex != NULL) {
| 0-200189 | ||||||||||||||||||
| 126 | ret = (int)bio_call_callback(a, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL); | - | ||||||||||||||||||
| 127 | if (ret <= 0)
| 0-1 | ||||||||||||||||||
| 128 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 129 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | if ((a->method != NULL) && (a->method->destroy != NULL))
| 0-200190 | ||||||||||||||||||
| 132 | a->method->destroy(a); executed 184588 times by 12 tests: a->method->destroy(a);Executed by:
| 184588 | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | CRYPTO_THREAD_lock_free(a->lock); | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | OPENSSL_free(a); | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | return 1; executed 200190 times by 12 tests: return 1;Executed by:
| 200190 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | void BIO_set_data(BIO *a, void *ptr) | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | a->ptr = ptr; | - | ||||||||||||||||||
| 146 | } executed 82597 times by 12 tests: end of blockExecuted by:
| 82597 | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | void *BIO_get_data(BIO *a) | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | return a->ptr; executed 492225 times by 3 tests: return a->ptr;Executed by:
| 492225 | ||||||||||||||||||
| 151 | } | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | void BIO_set_init(BIO *a, int init) | - | ||||||||||||||||||
| 154 | { | - | ||||||||||||||||||
| 155 | a->init = init; | - | ||||||||||||||||||
| 156 | } executed 117338 times by 12 tests: end of blockExecuted by:
| 117338 | ||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | int BIO_get_init(BIO *a) | - | ||||||||||||||||||
| 159 | { | - | ||||||||||||||||||
| 160 | return a->init; executed 326 times by 1 test: return a->init;Executed by:
| 326 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | void BIO_set_shutdown(BIO *a, int shut) | - | ||||||||||||||||||
| 164 | { | - | ||||||||||||||||||
| 165 | a->shutdown = shut; | - | ||||||||||||||||||
| 166 | } executed 487 times by 1 test: end of blockExecuted by:
| 487 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | int BIO_get_shutdown(BIO *a) | - | ||||||||||||||||||
| 169 | { | - | ||||||||||||||||||
| 170 | return a->shutdown; executed 487 times by 1 test: return a->shutdown;Executed by:
| 487 | ||||||||||||||||||
| 171 | } | - | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | void BIO_vfree(BIO *a) | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | BIO_free(a); | - | ||||||||||||||||||
| 176 | } executed 561 times by 1 test: end of blockExecuted by:
| 561 | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | int BIO_up_ref(BIO *a) | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | int i; | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | if (CRYPTO_UP_REF(&a->references, &i, a->lock) <= 0)
| 0-4795 | ||||||||||||||||||
| 183 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | REF_PRINT_COUNT("BIO", a); | - | ||||||||||||||||||
| 186 | REF_ASSERT_ISNT(i < 2); | - | ||||||||||||||||||
| 187 | return ((i > 1) ? 1 : 0); executed 4795 times by 1 test: return ((i > 1) ? 1 : 0);Executed by:
| 0-4795 | ||||||||||||||||||
| 188 | } | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | void BIO_clear_flags(BIO *b, int flags) | - | ||||||||||||||||||
| 191 | { | - | ||||||||||||||||||
| 192 | b->flags &= ~flags; | - | ||||||||||||||||||
| 193 | } executed 1773137 times by 1 test: end of blockExecuted by:
| 1773137 | ||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | int BIO_test_flags(const BIO *b, int flags) | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | return (b->flags & flags); executed 349329 times by 1 test: return (b->flags & flags);Executed by:
| 349329 | ||||||||||||||||||
| 198 | } | - | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | void BIO_set_flags(BIO *b, int flags) | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | b->flags |= flags; | - | ||||||||||||||||||
| 203 | } executed 339941 times by 12 tests: end of blockExecuted by:
| 339941 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | BIO_callback_fn BIO_get_callback(const BIO *b) | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | return b->callback; executed 36938 times by 1 test: return b->callback;Executed by:
| 36938 | ||||||||||||||||||
| 208 | } | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | void BIO_set_callback(BIO *b, BIO_callback_fn cb) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | b->callback = cb; | - | ||||||||||||||||||
| 213 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b) | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | return b->callback_ex; never executed: return b->callback_ex; | 0 | ||||||||||||||||||
| 218 | } | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex cb) | - | ||||||||||||||||||
| 221 | { | - | ||||||||||||||||||
| 222 | b->callback_ex = cb; | - | ||||||||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | void BIO_set_callback_arg(BIO *b, char *arg) | - | ||||||||||||||||||
| 226 | { | - | ||||||||||||||||||
| 227 | b->cb_arg = arg; | - | ||||||||||||||||||
| 228 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | char *BIO_get_callback_arg(const BIO *b) | - | ||||||||||||||||||
| 231 | { | - | ||||||||||||||||||
| 232 | return b->cb_arg; executed 2 times by 1 test: return b->cb_arg;Executed by:
| 2 | ||||||||||||||||||
| 233 | } | - | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | const char *BIO_method_name(const BIO *b) | - | ||||||||||||||||||
| 236 | { | - | ||||||||||||||||||
| 237 | return b->method->name; never executed: return b->method->name; | 0 | ||||||||||||||||||
| 238 | } | - | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | int BIO_method_type(const BIO *b) | - | ||||||||||||||||||
| 241 | { | - | ||||||||||||||||||
| 242 | return b->method->type; executed 65 times by 1 test: return b->method->type;Executed by:
| 65 | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | /* | - | ||||||||||||||||||
| 246 | * This is essentially the same as BIO_read_ex() except that it allows | - | ||||||||||||||||||
| 247 | * 0 or a negative value to indicate failure (retryable or not) in the return. | - | ||||||||||||||||||
| 248 | * This is for compatibility with the old style BIO_read(), where existing code | - | ||||||||||||||||||
| 249 | * may make assumptions about the return value that it might get. | - | ||||||||||||||||||
| 250 | */ | - | ||||||||||||||||||
| 251 | static int bio_read_intern(BIO *b, void *data, size_t dlen, size_t *readbytes) | - | ||||||||||||||||||
| 252 | { | - | ||||||||||||||||||
| 253 | int ret; | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
| 0-1093110 | ||||||||||||||||||
| 256 | BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 257 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 258 | } | - | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | if ((b->callback != NULL || b->callback_ex != NULL) &&
| 0-1093110 | ||||||||||||||||||
| 261 | ((ret = (int)bio_call_callback(b, BIO_CB_READ, data, dlen, 0, 0L, 1L,
| 0 | ||||||||||||||||||
| 262 | NULL)) <= 0))
| 0 | ||||||||||||||||||
| 263 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | if (!b->init) {
| 0-1093110 | ||||||||||||||||||
| 266 | BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNINITIALIZED); | - | ||||||||||||||||||
| 267 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 268 | } | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | ret = b->method->bread(b, data, dlen, readbytes); | - | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | if (ret > 0)
| 114081-979029 | ||||||||||||||||||
| 273 | b->num_read += (uint64_t)*readbytes; executed 979029 times by 1 test: b->num_read += (uint64_t)*readbytes;Executed by:
| 979029 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | if (b->callback != NULL || b->callback_ex != NULL)
| 0-1093110 | ||||||||||||||||||
| 276 | ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, data, never executed: ret = (int)bio_call_callback(b, 0x02 | 0x80, data, dlen, 0, 0L, ret, readbytes); | 0 | ||||||||||||||||||
| 277 | dlen, 0, 0L, ret, readbytes); never executed: ret = (int)bio_call_callback(b, 0x02 | 0x80, data, dlen, 0, 0L, ret, readbytes); | 0 | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | /* Shouldn't happen */ | - | ||||||||||||||||||
| 280 | if (ret > 0 && *readbytes > dlen) {
| 0-979029 | ||||||||||||||||||
| 281 | BIOerr(BIO_F_BIO_READ_INTERN, ERR_R_INTERNAL_ERROR); | - | ||||||||||||||||||
| 282 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 283 | } | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | return ret; executed 1093110 times by 1 test: return ret;Executed by:
| 1093110 | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | int BIO_read(BIO *b, void *data, int dlen) | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | size_t readbytes; | - | ||||||||||||||||||
| 291 | int ret; | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | if (dlen < 0)
| 0-1093107 | ||||||||||||||||||
| 294 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | ret = bio_read_intern(b, data, (size_t)dlen, &readbytes); | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | if (ret > 0) {
| 114081-979026 | ||||||||||||||||||
| 299 | /* *readbytes should always be <= dlen */ | - | ||||||||||||||||||
| 300 | ret = (int)readbytes; | - | ||||||||||||||||||
| 301 | } executed 979026 times by 1 test: end of blockExecuted by:
| 979026 | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | return ret; executed 1093107 times by 1 test: return ret;Executed by:
| 1093107 | ||||||||||||||||||
| 304 | } | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes) | - | ||||||||||||||||||
| 307 | { | - | ||||||||||||||||||
| 308 | int ret; | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | ret = bio_read_intern(b, data, dlen, readbytes); | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | if (ret > 0)
| 0-3 | ||||||||||||||||||
| 313 | ret = 1; executed 3 times by 1 test: ret = 1;Executed by:
| 3 | ||||||||||||||||||
| 314 | else | - | ||||||||||||||||||
| 315 | ret = 0; never executed: ret = 0; | 0 | ||||||||||||||||||
| 316 | - | |||||||||||||||||||
| 317 | return ret; executed 3 times by 1 test: return ret;Executed by:
| 3 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | static int bio_write_intern(BIO *b, const void *data, size_t dlen, | - | ||||||||||||||||||
| 321 | size_t *written) | - | ||||||||||||||||||
| 322 | { | - | ||||||||||||||||||
| 323 | int ret; | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | if (b == NULL)
| 0-13188871 | ||||||||||||||||||
| 326 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | if ((b->method == NULL) || (b->method->bwrite == NULL)) {
| 0-13188871 | ||||||||||||||||||
| 329 | BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 330 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 331 | } | - | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | if ((b->callback != NULL || b->callback_ex != NULL) &&
| 0-13188870 | ||||||||||||||||||
| 334 | ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L,
| 0-1 | ||||||||||||||||||
| 335 | NULL)) <= 0))
| 0-1 | ||||||||||||||||||
| 336 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | if (!b->init) {
| 88-13188783 | ||||||||||||||||||
| 339 | BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNINITIALIZED); | - | ||||||||||||||||||
| 340 | return -2; executed 88 times by 1 test: return -2;Executed by:
| 88 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | ret = b->method->bwrite(b, data, dlen, written); | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | if (ret > 0)
| 3588-13185195 | ||||||||||||||||||
| 346 | b->num_write += (uint64_t)*written; executed 13185195 times by 12 tests: b->num_write += (uint64_t)*written;Executed by:
| 13185195 | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | if (b->callback != NULL || b->callback_ex != NULL)
| 0-13188782 | ||||||||||||||||||
| 349 | ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data, executed 1 time by 1 test: ret = (int)bio_call_callback(b, 0x03 | 0x80, data, dlen, 0, 0L, ret, written);Executed by:
| 1 | ||||||||||||||||||
| 350 | dlen, 0, 0L, ret, written); executed 1 time by 1 test: ret = (int)bio_call_callback(b, 0x03 | 0x80, data, dlen, 0, 0L, ret, written);Executed by:
| 1 | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | return ret; executed 13188783 times by 12 tests: return ret;Executed by:
| 13188783 | ||||||||||||||||||
| 353 | } | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | int BIO_write(BIO *b, const void *data, int dlen) | - | ||||||||||||||||||
| 356 | { | - | ||||||||||||||||||
| 357 | size_t written; | - | ||||||||||||||||||
| 358 | int ret; | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | if (dlen < 0)
| 0-13089765 | ||||||||||||||||||
| 361 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | ret = bio_write_intern(b, data, (size_t)dlen, &written); | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | if (ret > 0) {
| 3676-13086089 | ||||||||||||||||||
| 366 | /* *written should always be <= dlen */ | - | ||||||||||||||||||
| 367 | ret = (int)written; | - | ||||||||||||||||||
| 368 | } executed 13086089 times by 12 tests: end of blockExecuted by:
| 13086089 | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | return ret; executed 13089765 times by 12 tests: return ret;Executed by:
| 13089765 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written) | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | int ret; | - | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | ret = bio_write_intern(b, data, dlen, written); | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | if (ret > 0)
| 0-99106 | ||||||||||||||||||
| 380 | ret = 1; executed 99106 times by 3 tests: ret = 1;Executed by:
| 99106 | ||||||||||||||||||
| 381 | else | - | ||||||||||||||||||
| 382 | ret = 0; never executed: ret = 0; | 0 | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | return ret; executed 99106 times by 3 tests: return ret;Executed by:
| 99106 | ||||||||||||||||||
| 385 | } | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | int BIO_puts(BIO *b, const char *buf) | - | ||||||||||||||||||
| 388 | { | - | ||||||||||||||||||
| 389 | int ret; | - | ||||||||||||||||||
| 390 | size_t written = 0; | - | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
| 0-6180367 | ||||||||||||||||||
| 393 | BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 394 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 395 | } | - | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | if (b->callback != NULL || b->callback_ex != NULL) {
| 0-6180366 | ||||||||||||||||||
| 398 | ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL); | - | ||||||||||||||||||
| 399 | if (ret <= 0)
| 0-1 | ||||||||||||||||||
| 400 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 401 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | if (!b->init) {
| 0-6180367 | ||||||||||||||||||
| 404 | BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED); | - | ||||||||||||||||||
| 405 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 406 | } | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | ret = b->method->bputs(b, buf); | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | if (ret > 0) {
| 0-6180367 | ||||||||||||||||||
| 411 | b->num_write += (uint64_t)ret; | - | ||||||||||||||||||
| 412 | written = ret; | - | ||||||||||||||||||
| 413 | ret = 1; | - | ||||||||||||||||||
| 414 | } executed 6180367 times by 1 test: end of blockExecuted by:
| 6180367 | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | if (b->callback != NULL || b->callback_ex != NULL)
| 0-6180366 | ||||||||||||||||||
| 417 | ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0, executed 1 time by 1 test: ret = (int)bio_call_callback(b, 0x04 | 0x80, buf, 0, 0, 0L, ret, &written);Executed by:
| 1 | ||||||||||||||||||
| 418 | 0L, ret, &written); executed 1 time by 1 test: ret = (int)bio_call_callback(b, 0x04 | 0x80, buf, 0, 0, 0L, ret, &written);Executed by:
| 1 | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | if (ret > 0) {
| 0-6180367 | ||||||||||||||||||
| 421 | if (written > INT_MAX) {
| 0-6180367 | ||||||||||||||||||
| 422 | BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG); | - | ||||||||||||||||||
| 423 | ret = -1; | - | ||||||||||||||||||
| 424 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 425 | ret = (int)written; | - | ||||||||||||||||||
| 426 | } executed 6180367 times by 1 test: end of blockExecuted by:
| 6180367 | ||||||||||||||||||
| 427 | } | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | return ret; executed 6180367 times by 1 test: return ret;Executed by:
| 6180367 | ||||||||||||||||||
| 430 | } | - | ||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | int BIO_gets(BIO *b, char *buf, int size) | - | ||||||||||||||||||
| 433 | { | - | ||||||||||||||||||
| 434 | int ret; | - | ||||||||||||||||||
| 435 | size_t readbytes = 0; | - | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) {
| 0-507747 | ||||||||||||||||||
| 438 | BIOerr(BIO_F_BIO_GETS, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 439 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | if (size < 0) {
| 0-507747 | ||||||||||||||||||
| 443 | BIOerr(BIO_F_BIO_GETS, BIO_R_INVALID_ARGUMENT); | - | ||||||||||||||||||
| 444 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 445 | } | - | ||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | if (b->callback != NULL || b->callback_ex != NULL) {
| 0-507747 | ||||||||||||||||||
| 448 | ret = (int)bio_call_callback(b, BIO_CB_GETS, buf, size, 0, 0L, 1, NULL); | - | ||||||||||||||||||
| 449 | if (ret <= 0)
| 0 | ||||||||||||||||||
| 450 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 451 | } never executed: end of block | 0 | ||||||||||||||||||
| 452 | - | |||||||||||||||||||
| 453 | if (!b->init) {
| 0-507747 | ||||||||||||||||||
| 454 | BIOerr(BIO_F_BIO_GETS, BIO_R_UNINITIALIZED); | - | ||||||||||||||||||
| 455 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 456 | } | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | ret = b->method->bgets(b, buf, size); | - | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | if (ret > 0) {
| 7064-500683 | ||||||||||||||||||
| 461 | readbytes = ret; | - | ||||||||||||||||||
| 462 | ret = 1; | - | ||||||||||||||||||
| 463 | } executed 500683 times by 1 test: end of blockExecuted by:
| 500683 | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | if (b->callback != NULL || b->callback_ex != NULL)
| 0-507747 | ||||||||||||||||||
| 466 | ret = (int)bio_call_callback(b, BIO_CB_GETS | BIO_CB_RETURN, buf, size, never executed: ret = (int)bio_call_callback(b, 0x05 | 0x80, buf, size, 0, 0L, ret, &readbytes); | 0 | ||||||||||||||||||
| 467 | 0, 0L, ret, &readbytes); never executed: ret = (int)bio_call_callback(b, 0x05 | 0x80, buf, size, 0, 0L, ret, &readbytes); | 0 | ||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | if (ret > 0) {
| 7064-500683 | ||||||||||||||||||
| 470 | /* Shouldn't happen */ | - | ||||||||||||||||||
| 471 | if (readbytes > (size_t)size)
| 0-500683 | ||||||||||||||||||
| 472 | ret = -1; never executed: ret = -1; | 0 | ||||||||||||||||||
| 473 | else | - | ||||||||||||||||||
| 474 | ret = (int)readbytes; executed 500683 times by 1 test: ret = (int)readbytes;Executed by:
| 500683 | ||||||||||||||||||
| 475 | } | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | return ret; executed 507747 times by 1 test: return ret;Executed by:
| 507747 | ||||||||||||||||||
| 478 | } | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | int BIO_indent(BIO *b, int indent, int max) | - | ||||||||||||||||||
| 481 | { | - | ||||||||||||||||||
| 482 | if (indent < 0)
| 0-1476595 | ||||||||||||||||||
| 483 | indent = 0; never executed: indent = 0; | 0 | ||||||||||||||||||
| 484 | if (indent > max)
| 0-1476595 | ||||||||||||||||||
| 485 | indent = max; never executed: indent = max; | 0 | ||||||||||||||||||
| 486 | while (indent--)
| 1476595-5429877 | ||||||||||||||||||
| 487 | if (BIO_puts(b, " ") != 1)
| 0-5429877 | ||||||||||||||||||
| 488 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 489 | return 1; executed 1476595 times by 1 test: return 1;Executed by:
| 1476595 | ||||||||||||||||||
| 490 | } | - | ||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 | long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) | - | ||||||||||||||||||
| 493 | { | - | ||||||||||||||||||
| 494 | int i; | - | ||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | i = iarg; | - | ||||||||||||||||||
| 497 | return BIO_ctrl(b, cmd, larg, (char *)&i); executed 9822 times by 1 test: return BIO_ctrl(b, cmd, larg, (char *)&i);Executed by:
| 9822 | ||||||||||||||||||
| 498 | } | - | ||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | void *BIO_ptr_ctrl(BIO *b, int cmd, long larg) | - | ||||||||||||||||||
| 501 | { | - | ||||||||||||||||||
| 502 | void *p = NULL; | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | if (BIO_ctrl(b, cmd, larg, (char *)&p) <= 0)
| 0-2 | ||||||||||||||||||
| 505 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 506 | else | - | ||||||||||||||||||
| 507 | return p; executed 2 times by 1 test: return p;Executed by:
| 2 | ||||||||||||||||||
| 508 | } | - | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) | - | ||||||||||||||||||
| 511 | { | - | ||||||||||||||||||
| 512 | long ret; | - | ||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | if (b == NULL)
| 0-330333 | ||||||||||||||||||
| 515 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | if ((b->method == NULL) || (b->method->ctrl == NULL)) {
| 0-330333 | ||||||||||||||||||
| 518 | BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 519 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 520 | } | - | ||||||||||||||||||
| 521 | - | |||||||||||||||||||
| 522 | if (b->callback != NULL || b->callback_ex != NULL) {
| 0-330333 | ||||||||||||||||||
| 523 | ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL); | - | ||||||||||||||||||
| 524 | if (ret <= 0)
| 0 | ||||||||||||||||||
| 525 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 526 | } never executed: end of block | 0 | ||||||||||||||||||
| 527 | - | |||||||||||||||||||
| 528 | ret = b->method->ctrl(b, cmd, larg, parg); | - | ||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 | if (b->callback != NULL || b->callback_ex != NULL)
| 0-330333 | ||||||||||||||||||
| 531 | ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd, never executed: ret = bio_call_callback(b, 0x06 | 0x80, parg, 0, cmd, larg, ret, ((void *)0) ); | 0 | ||||||||||||||||||
| 532 | larg, ret, NULL); never executed: ret = bio_call_callback(b, 0x06 | 0x80, parg, 0, cmd, larg, ret, ((void *)0) ); | 0 | ||||||||||||||||||
| 533 | - | |||||||||||||||||||
| 534 | return ret; executed 330333 times by 12 tests: return ret;Executed by:
| 330333 | ||||||||||||||||||
| 535 | } | - | ||||||||||||||||||
| 536 | - | |||||||||||||||||||
| 537 | long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) | - | ||||||||||||||||||
| 538 | { | - | ||||||||||||||||||
| 539 | long ret; | - | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | if (b == NULL)
| 0 | ||||||||||||||||||
| 542 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | if ((b->method == NULL) || (b->method->callback_ctrl == NULL)
| 0 | ||||||||||||||||||
| 545 | || (cmd != BIO_CTRL_SET_CALLBACK)) {
| 0 | ||||||||||||||||||
| 546 | BIOerr(BIO_F_BIO_CALLBACK_CTRL, BIO_R_UNSUPPORTED_METHOD); | - | ||||||||||||||||||
| 547 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 548 | } | - | ||||||||||||||||||
| 549 | - | |||||||||||||||||||
| 550 | if (b->callback != NULL || b->callback_ex != NULL) {
| 0 | ||||||||||||||||||
| 551 | ret = bio_call_callback(b, BIO_CB_CTRL, (void *)&fp, 0, cmd, 0, 1L, | - | ||||||||||||||||||
| 552 | NULL); | - | ||||||||||||||||||
| 553 | if (ret <= 0)
| 0 | ||||||||||||||||||
| 554 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 555 | } never executed: end of block | 0 | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | ret = b->method->callback_ctrl(b, cmd, fp); | - | ||||||||||||||||||
| 558 | - | |||||||||||||||||||
| 559 | if (b->callback != NULL || b->callback_ex != NULL)
| 0 | ||||||||||||||||||
| 560 | ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, (void *)&fp, 0, never executed: ret = bio_call_callback(b, 0x06 | 0x80, (void *)&fp, 0, cmd, 0, ret, ((void *)0) ); | 0 | ||||||||||||||||||
| 561 | cmd, 0, ret, NULL); never executed: ret = bio_call_callback(b, 0x06 | 0x80, (void *)&fp, 0, cmd, 0, ret, ((void *)0) ); | 0 | ||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 564 | } | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | /* | - | ||||||||||||||||||
| 567 | * It is unfortunate to duplicate in functions what the BIO_(w)pending macros | - | ||||||||||||||||||
| 568 | * do; but those macros have inappropriate return type, and for interfacing | - | ||||||||||||||||||
| 569 | * from other programming languages, C macros aren't much of a help anyway. | - | ||||||||||||||||||
| 570 | */ | - | ||||||||||||||||||
| 571 | size_t BIO_ctrl_pending(BIO *bio) | - | ||||||||||||||||||
| 572 | { | - | ||||||||||||||||||
| 573 | return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); executed 3225 times by 1 test: return BIO_ctrl(bio, 10, 0, ((void *)0) );Executed by:
| 3225 | ||||||||||||||||||
| 574 | } | - | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | size_t BIO_ctrl_wpending(BIO *bio) | - | ||||||||||||||||||
| 577 | { | - | ||||||||||||||||||
| 578 | return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); never executed: return BIO_ctrl(bio, 13, 0, ((void *)0) ); | 0 | ||||||||||||||||||
| 579 | } | - | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | /* put the 'bio' on the end of b's list of operators */ | - | ||||||||||||||||||
| 582 | BIO *BIO_push(BIO *b, BIO *bio) | - | ||||||||||||||||||
| 583 | { | - | ||||||||||||||||||
| 584 | BIO *lb; | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | if (b == NULL)
| 0-49329 | ||||||||||||||||||
| 587 | return bio; never executed: return bio; | 0 | ||||||||||||||||||
| 588 | lb = b; | - | ||||||||||||||||||
| 589 | while (lb->next_bio != NULL)
| 0-49329 | ||||||||||||||||||
| 590 | lb = lb->next_bio; never executed: lb = lb->next_bio; | 0 | ||||||||||||||||||
| 591 | lb->next_bio = bio; | - | ||||||||||||||||||
| 592 | if (bio != NULL)
| 2-49327 | ||||||||||||||||||
| 593 | bio->prev_bio = lb; executed 49327 times by 12 tests: bio->prev_bio = lb;Executed by:
| 49327 | ||||||||||||||||||
| 594 | /* called to do internal processing */ | - | ||||||||||||||||||
| 595 | BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); | - | ||||||||||||||||||
| 596 | return b; executed 49329 times by 12 tests: return b;Executed by:
| 49329 | ||||||||||||||||||
| 597 | } | - | ||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | /* Remove the first and return the rest */ | - | ||||||||||||||||||
| 600 | BIO *BIO_pop(BIO *b) | - | ||||||||||||||||||
| 601 | { | - | ||||||||||||||||||
| 602 | BIO *ret; | - | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | if (b == NULL)
| 0-9518 | ||||||||||||||||||
| 605 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 606 | ret = b->next_bio; | - | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | BIO_ctrl(b, BIO_CTRL_POP, 0, b); | - | ||||||||||||||||||
| 609 | - | |||||||||||||||||||
| 610 | if (b->prev_bio != NULL)
| 3-9515 | ||||||||||||||||||
| 611 | b->prev_bio->next_bio = b->next_bio; executed 3 times by 1 test: b->prev_bio->next_bio = b->next_bio;Executed by:
| 3 | ||||||||||||||||||
| 612 | if (b->next_bio != NULL)
| 5-9513 | ||||||||||||||||||
| 613 | b->next_bio->prev_bio = b->prev_bio; executed 9513 times by 1 test: b->next_bio->prev_bio = b->prev_bio;Executed by:
| 9513 | ||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | b->next_bio = NULL; | - | ||||||||||||||||||
| 616 | b->prev_bio = NULL; | - | ||||||||||||||||||
| 617 | return ret; executed 9518 times by 1 test: return ret;Executed by:
| 9518 | ||||||||||||||||||
| 618 | } | - | ||||||||||||||||||
| 619 | - | |||||||||||||||||||
| 620 | BIO *BIO_get_retry_BIO(BIO *bio, int *reason) | - | ||||||||||||||||||
| 621 | { | - | ||||||||||||||||||
| 622 | BIO *b, *last; | - | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | b = last = bio; | - | ||||||||||||||||||
| 625 | for (;;) { | - | ||||||||||||||||||
| 626 | if (!BIO_should_retry(b))
| 0 | ||||||||||||||||||
| 627 | break; never executed: break; | 0 | ||||||||||||||||||
| 628 | last = b; | - | ||||||||||||||||||
| 629 | b = b->next_bio; | - | ||||||||||||||||||
| 630 | if (b == NULL)
| 0 | ||||||||||||||||||
| 631 | break; never executed: break; | 0 | ||||||||||||||||||
| 632 | } never executed: end of block | 0 | ||||||||||||||||||
| 633 | if (reason != NULL)
| 0 | ||||||||||||||||||
| 634 | *reason = last->retry_reason; never executed: *reason = last->retry_reason; | 0 | ||||||||||||||||||
| 635 | return last; never executed: return last; | 0 | ||||||||||||||||||
| 636 | } | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | int BIO_get_retry_reason(BIO *bio) | - | ||||||||||||||||||
| 639 | { | - | ||||||||||||||||||
| 640 | return bio->retry_reason; never executed: return bio->retry_reason; | 0 | ||||||||||||||||||
| 641 | } | - | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | void BIO_set_retry_reason(BIO *bio, int reason) | - | ||||||||||||||||||
| 644 | { | - | ||||||||||||||||||
| 645 | bio->retry_reason = reason; | - | ||||||||||||||||||
| 646 | } executed 13307 times by 1 test: end of blockExecuted by:
| 13307 | ||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | BIO *BIO_find_type(BIO *bio, int type) | - | ||||||||||||||||||
| 649 | { | - | ||||||||||||||||||
| 650 | int mt, mask; | - | ||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 | if (bio == NULL)
| 0-4337 | ||||||||||||||||||
| 653 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 654 | mask = type & 0xff; | - | ||||||||||||||||||
| 655 | do { | - | ||||||||||||||||||
| 656 | if (bio->method != NULL) {
| 0-4348 | ||||||||||||||||||
| 657 | mt = bio->method->type; | - | ||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | if (!mask) {
| 192-4156 | ||||||||||||||||||
| 660 | if (mt & type)
| 0-4156 | ||||||||||||||||||
| 661 | return bio; executed 4156 times by 1 test: return bio;Executed by:
| 4156 | ||||||||||||||||||
| 662 | } else if (mt == type) never executed: end of block
| 0-181 | ||||||||||||||||||
| 663 | return bio; executed 181 times by 1 test: return bio;Executed by:
| 181 | ||||||||||||||||||
| 664 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||
| 665 | bio = bio->next_bio; | - | ||||||||||||||||||
| 666 | } while (bio != NULL); executed 11 times by 1 test: end of blockExecuted by:
| 0-11 | ||||||||||||||||||
| 667 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 668 | } | - | ||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | BIO *BIO_next(BIO *b) | - | ||||||||||||||||||
| 671 | { | - | ||||||||||||||||||
| 672 | if (b == NULL)
| 0-336075 | ||||||||||||||||||
| 673 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 674 | return b->next_bio; executed 336075 times by 12 tests: return b->next_bio;Executed by:
| 336075 | ||||||||||||||||||
| 675 | } | - | ||||||||||||||||||
| 676 | - | |||||||||||||||||||
| 677 | void BIO_set_next(BIO *b, BIO *next) | - | ||||||||||||||||||
| 678 | { | - | ||||||||||||||||||
| 679 | b->next_bio = next; | - | ||||||||||||||||||
| 680 | } executed 483 times by 1 test: end of blockExecuted by:
| 483 | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | void BIO_free_all(BIO *bio) | - | ||||||||||||||||||
| 683 | { | - | ||||||||||||||||||
| 684 | BIO *b; | - | ||||||||||||||||||
| 685 | int ref; | - | ||||||||||||||||||
| 686 | - | |||||||||||||||||||
| 687 | while (bio != NULL) {
| 70378-96843 | ||||||||||||||||||
| 688 | b = bio; | - | ||||||||||||||||||
| 689 | ref = b->references; | - | ||||||||||||||||||
| 690 | bio = bio->next_bio; | - | ||||||||||||||||||
| 691 | BIO_free(b); | - | ||||||||||||||||||
| 692 | /* Since ref count > 1, don't free anyone else. */ | - | ||||||||||||||||||
| 693 | if (ref > 1)
| 4602-92241 | ||||||||||||||||||
| 694 | break; executed 4602 times by 1 test: break;Executed by:
| 4602 | ||||||||||||||||||
| 695 | } executed 92241 times by 12 tests: end of blockExecuted by:
| 92241 | ||||||||||||||||||
| 696 | } executed 74980 times by 12 tests: end of blockExecuted by:
| 74980 | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | BIO *BIO_dup_chain(BIO *in) | - | ||||||||||||||||||
| 699 | { | - | ||||||||||||||||||
| 700 | BIO *ret = NULL, *eoc = NULL, *bio, *new_bio; | - | ||||||||||||||||||
| 701 | - | |||||||||||||||||||
| 702 | for (bio = in; bio != NULL; bio = bio->next_bio) {
| 0 | ||||||||||||||||||
| 703 | if ((new_bio = BIO_new(bio->method)) == NULL)
| 0 | ||||||||||||||||||
| 704 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 705 | new_bio->callback = bio->callback; | - | ||||||||||||||||||
| 706 | new_bio->callback_ex = bio->callback_ex; | - | ||||||||||||||||||
| 707 | new_bio->cb_arg = bio->cb_arg; | - | ||||||||||||||||||
| 708 | new_bio->init = bio->init; | - | ||||||||||||||||||
| 709 | new_bio->shutdown = bio->shutdown; | - | ||||||||||||||||||
| 710 | new_bio->flags = bio->flags; | - | ||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | /* This will let SSL_s_sock() work with stdin/stdout */ | - | ||||||||||||||||||
| 713 | new_bio->num = bio->num; | - | ||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | if (!BIO_dup_state(bio, (char *)new_bio)) {
| 0 | ||||||||||||||||||
| 716 | BIO_free(new_bio); | - | ||||||||||||||||||
| 717 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 718 | } | - | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | /* copy app data */ | - | ||||||||||||||||||
| 721 | if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
| 0 | ||||||||||||||||||
| 722 | &bio->ex_data)) {
| 0 | ||||||||||||||||||
| 723 | BIO_free(new_bio); | - | ||||||||||||||||||
| 724 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 725 | } | - | ||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | if (ret == NULL) {
| 0 | ||||||||||||||||||
| 728 | eoc = new_bio; | - | ||||||||||||||||||
| 729 | ret = eoc; | - | ||||||||||||||||||
| 730 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 731 | BIO_push(eoc, new_bio); | - | ||||||||||||||||||
| 732 | eoc = new_bio; | - | ||||||||||||||||||
| 733 | } never executed: end of block | 0 | ||||||||||||||||||
| 734 | } | - | ||||||||||||||||||
| 735 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 736 | err: | - | ||||||||||||||||||
| 737 | BIO_free_all(ret); | - | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 740 | } | - | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | void BIO_copy_next_retry(BIO *b) | - | ||||||||||||||||||
| 743 | { | - | ||||||||||||||||||
| 744 | BIO_set_flags(b, BIO_get_retry_flags(b->next_bio)); | - | ||||||||||||||||||
| 745 | b->retry_reason = b->next_bio->retry_reason; | - | ||||||||||||||||||
| 746 | } executed 262367 times by 1 test: end of blockExecuted by:
| 262367 | ||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | int BIO_set_ex_data(BIO *bio, int idx, void *data) | - | ||||||||||||||||||
| 749 | { | - | ||||||||||||||||||
| 750 | return CRYPTO_set_ex_data(&(bio->ex_data), idx, data); never executed: return CRYPTO_set_ex_data(&(bio->ex_data), idx, data); | 0 | ||||||||||||||||||
| 751 | } | - | ||||||||||||||||||
| 752 | - | |||||||||||||||||||
| 753 | void *BIO_get_ex_data(BIO *bio, int idx) | - | ||||||||||||||||||
| 754 | { | - | ||||||||||||||||||
| 755 | return CRYPTO_get_ex_data(&(bio->ex_data), idx); never executed: return CRYPTO_get_ex_data(&(bio->ex_data), idx); | 0 | ||||||||||||||||||
| 756 | } | - | ||||||||||||||||||
| 757 | - | |||||||||||||||||||
| 758 | uint64_t BIO_number_read(BIO *bio) | - | ||||||||||||||||||
| 759 | { | - | ||||||||||||||||||
| 760 | if (bio)
| 0-191 | ||||||||||||||||||
| 761 | return bio->num_read; executed 191 times by 1 test: return bio->num_read;Executed by:
| 191 | ||||||||||||||||||
| 762 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 763 | } | - | ||||||||||||||||||
| 764 | - | |||||||||||||||||||
| 765 | uint64_t BIO_number_written(BIO *bio) | - | ||||||||||||||||||
| 766 | { | - | ||||||||||||||||||
| 767 | if (bio)
| 0-191 | ||||||||||||||||||
| 768 | return bio->num_write; executed 191 times by 1 test: return bio->num_write;Executed by:
| 191 | ||||||||||||||||||
| 769 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 770 | } | - | ||||||||||||||||||
| 771 | - | |||||||||||||||||||
| 772 | void bio_free_ex_data(BIO *bio) | - | ||||||||||||||||||
| 773 | { | - | ||||||||||||||||||
| 774 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data); | - | ||||||||||||||||||
| 775 | } never executed: end of block | 0 | ||||||||||||||||||
| 776 | - | |||||||||||||||||||
| 777 | void bio_cleanup(void) | - | ||||||||||||||||||
| 778 | { | - | ||||||||||||||||||
| 779 | #ifndef OPENSSL_NO_SOCK | - | ||||||||||||||||||
| 780 | bio_sock_cleanup_int(); | - | ||||||||||||||||||
| 781 | CRYPTO_THREAD_lock_free(bio_lookup_lock); | - | ||||||||||||||||||
| 782 | bio_lookup_lock = NULL; | - | ||||||||||||||||||
| 783 | #endif | - | ||||||||||||||||||
| 784 | CRYPTO_THREAD_lock_free(bio_type_lock); | - | ||||||||||||||||||
| 785 | bio_type_lock = NULL; | - | ||||||||||||||||||
| 786 | } executed 2076 times by 12 tests: end of blockExecuted by:
| 2076 | ||||||||||||||||||
| Source code | Switch to Preprocessed file |