| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bio/bf_null.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 "bio_lcl.h" | - | ||||||||||||
| 13 | #include "internal/cryptlib.h" | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | /* | - | ||||||||||||
| 16 | * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest | - | ||||||||||||
| 17 | */ | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 | static int nullf_write(BIO *h, const char *buf, int num); | - | ||||||||||||
| 20 | static int nullf_read(BIO *h, char *buf, int size); | - | ||||||||||||
| 21 | static int nullf_puts(BIO *h, const char *str); | - | ||||||||||||
| 22 | static int nullf_gets(BIO *h, char *str, int size); | - | ||||||||||||
| 23 | static long nullf_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||
| 24 | static long nullf_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp); | - | ||||||||||||
| 25 | static const BIO_METHOD methods_nullf = { | - | ||||||||||||
| 26 | BIO_TYPE_NULL_FILTER, | - | ||||||||||||
| 27 | "NULL filter", | - | ||||||||||||
| 28 | /* TODO: Convert to new style write function */ | - | ||||||||||||
| 29 | bwrite_conv, | - | ||||||||||||
| 30 | nullf_write, | - | ||||||||||||
| 31 | /* TODO: Convert to new style read function */ | - | ||||||||||||
| 32 | bread_conv, | - | ||||||||||||
| 33 | nullf_read, | - | ||||||||||||
| 34 | nullf_puts, | - | ||||||||||||
| 35 | nullf_gets, | - | ||||||||||||
| 36 | nullf_ctrl, | - | ||||||||||||
| 37 | NULL, | - | ||||||||||||
| 38 | NULL, | - | ||||||||||||
| 39 | nullf_callback_ctrl, | - | ||||||||||||
| 40 | }; | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | const BIO_METHOD *BIO_f_null(void) | - | ||||||||||||
| 43 | { | - | ||||||||||||
| 44 | return &methods_nullf; never executed: return &methods_nullf; | 0 | ||||||||||||
| 45 | } | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | static int nullf_read(BIO *b, char *out, int outl) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | int ret = 0; | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | if (out == NULL)
| 0 | ||||||||||||
| 52 | return 0; never executed: return 0; | 0 | ||||||||||||
| 53 | if (b->next_bio == NULL)
| 0 | ||||||||||||
| 54 | return 0; never executed: return 0; | 0 | ||||||||||||
| 55 | ret = BIO_read(b->next_bio, out, outl); | - | ||||||||||||
| 56 | BIO_clear_retry_flags(b); | - | ||||||||||||
| 57 | BIO_copy_next_retry(b); | - | ||||||||||||
| 58 | return ret; never executed: return ret; | 0 | ||||||||||||
| 59 | } | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | static int nullf_write(BIO *b, const char *in, int inl) | - | ||||||||||||
| 62 | { | - | ||||||||||||
| 63 | int ret = 0; | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | if ((in == NULL) || (inl <= 0))
| 0 | ||||||||||||
| 66 | return 0; never executed: return 0; | 0 | ||||||||||||
| 67 | if (b->next_bio == NULL)
| 0 | ||||||||||||
| 68 | return 0; never executed: return 0; | 0 | ||||||||||||
| 69 | ret = BIO_write(b->next_bio, in, inl); | - | ||||||||||||
| 70 | BIO_clear_retry_flags(b); | - | ||||||||||||
| 71 | BIO_copy_next_retry(b); | - | ||||||||||||
| 72 | return ret; never executed: return ret; | 0 | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | long ret; | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | if (b->next_bio == NULL)
| 0 | ||||||||||||
| 80 | return 0; never executed: return 0; | 0 | ||||||||||||
| 81 | switch (cmd) { | - | ||||||||||||
| 82 | case BIO_C_DO_STATE_MACHINE: never executed: case 101: | 0 | ||||||||||||
| 83 | BIO_clear_retry_flags(b); | - | ||||||||||||
| 84 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||
| 85 | BIO_copy_next_retry(b); | - | ||||||||||||
| 86 | break; never executed: break; | 0 | ||||||||||||
| 87 | case BIO_CTRL_DUP: never executed: case 12: | 0 | ||||||||||||
| 88 | ret = 0L; | - | ||||||||||||
| 89 | break; never executed: break; | 0 | ||||||||||||
| 90 | default: never executed: default: | 0 | ||||||||||||
| 91 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||
| 93 | return ret; never executed: return ret; | 0 | ||||||||||||
| 94 | } | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | static long nullf_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | long ret = 1; | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | if (b->next_bio == NULL)
| 0 | ||||||||||||
| 101 | return 0; never executed: return 0; | 0 | ||||||||||||
| 102 | switch (cmd) { | - | ||||||||||||
| 103 | default: never executed: default: | 0 | ||||||||||||
| 104 | ret = BIO_callback_ctrl(b->next_bio, cmd, fp); | - | ||||||||||||
| 105 | break; never executed: break; | 0 | ||||||||||||
| 106 | } | - | ||||||||||||
| 107 | return ret; never executed: return ret; | 0 | ||||||||||||
| 108 | } | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | static int nullf_gets(BIO *bp, char *buf, int size) | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 | if (bp->next_bio == NULL)
| 0 | ||||||||||||
| 113 | return 0; never executed: return 0; | 0 | ||||||||||||
| 114 | return BIO_gets(bp->next_bio, buf, size); never executed: return BIO_gets(bp->next_bio, buf, size); | 0 | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | static int nullf_puts(BIO *bp, const char *str) | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | if (bp->next_bio == NULL)
| 0 | ||||||||||||
| 120 | return 0; never executed: return 0; | 0 | ||||||||||||
| 121 | return BIO_puts(bp->next_bio, str); never executed: return BIO_puts(bp->next_bio, str); | 0 | ||||||||||||
| 122 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |