| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/record/ssl3_buffer.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n) | - | ||||||||||||
| 3 | { | - | ||||||||||||
| 4 | if (d !=
| 0 | ||||||||||||
| 5 | ((void *)0)
| 0 | ||||||||||||
| 6 | ) | - | ||||||||||||
| 7 | memcpy(b->buf, d, n); never executed: memcpy(b->buf, d, n); | 0 | ||||||||||||
| 8 | b->left = n; | - | ||||||||||||
| 9 | b->offset = 0; | - | ||||||||||||
| 10 | } never executed: end of block | 0 | ||||||||||||
| 11 | - | |||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | - | |||||||||||||
| 16 | void SSL3_BUFFER_clear(SSL3_BUFFER *b) | - | ||||||||||||
| 17 | { | - | ||||||||||||
| 18 | b->offset = 0; | - | ||||||||||||
| 19 | b->left = 0; | - | ||||||||||||
| 20 | } executed 16269 times by 2 tests: end of blockExecuted by:
| 16269 | ||||||||||||
| 21 | - | |||||||||||||
| 22 | void SSL3_BUFFER_release(SSL3_BUFFER *b) | - | ||||||||||||
| 23 | { | - | ||||||||||||
| 24 | CRYPTO_free(b->buf, __FILE__, 33); | - | ||||||||||||
| 25 | b->buf = | - | ||||||||||||
| 26 | ((void *)0) | - | ||||||||||||
| 27 | ; | - | ||||||||||||
| 28 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||
| 29 | - | |||||||||||||
| 30 | int ssl3_setup_read_buffer(SSL *s) | - | ||||||||||||
| 31 | { | - | ||||||||||||
| 32 | unsigned char *p; | - | ||||||||||||
| 33 | size_t len, align = 0, headerlen; | - | ||||||||||||
| 34 | SSL3_BUFFER *b; | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | b = (&(&s->rlayer)->rbuf); | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | if ((
| 400-9048 | ||||||||||||
| 39 | headerlen = 13; executed 400 times by 1 test: headerlen = 13;Executed by:
| 400 | ||||||||||||
| 40 | else | - | ||||||||||||
| 41 | headerlen = 5; executed 9048 times by 1 test: headerlen = 5;Executed by:
| 9048 | ||||||||||||
| 42 | - | |||||||||||||
| 43 | - | |||||||||||||
| 44 | align = (-5) & (8 - 1); | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | if (b->buf ==
| 1466-7982 | ||||||||||||
| 48 | ((void *)0)
| 1466-7982 | ||||||||||||
| 49 | ) { | - | ||||||||||||
| 50 | len = 16384 | - | ||||||||||||
| 51 | + (256 + 64) + headerlen + align; | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | if (ssl_allow_compression(s)
| 0-7982 | ||||||||||||
| 54 | len += 1024; never executed: len += 1024; | 0 | ||||||||||||
| 55 | - | |||||||||||||
| 56 | if (b->default_len > len
| 0-7982 | ||||||||||||
| 57 | len = b->default_len; never executed: len = b->default_len; | 0 | ||||||||||||
| 58 | if ((
| 0-7982 | ||||||||||||
| 59 | ((void *)0)
| 0-7982 | ||||||||||||
| 60 | ) { | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | - | |||||||||||||
| 63 | - | |||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | ossl_statem_fatal((s), (-1), (156), ((1|64)), | - | ||||||||||||
| 67 | __FILE__ | - | ||||||||||||
| 68 | , | - | ||||||||||||
| 69 | 70 | - | ||||||||||||
| 70 | ) | - | ||||||||||||
| 71 | ; | - | ||||||||||||
| 72 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | b->buf = p; | - | ||||||||||||
| 75 | b->len = len; | - | ||||||||||||
| 76 | } executed 7982 times by 1 test: end of blockExecuted by:
| 7982 | ||||||||||||
| 77 | - | |||||||||||||
| 78 | ((&s->rlayer)->packet = (&(b->buf[0]))); | - | ||||||||||||
| 79 | return executed 9448 times by 1 test: 1;return 1;Executed by:
executed 9448 times by 1 test: return 1;Executed by:
| 9448 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | unsigned char *p; | - | ||||||||||||
| 85 | size_t align = 0, headerlen; | - | ||||||||||||
| 86 | SSL3_BUFFER *wb; | - | ||||||||||||
| 87 | size_t currpipe; | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | s->rlayer.numwpipes = numwpipes; | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | if (len == 0
| 0-9354 | ||||||||||||
| 92 | if ((
| 400-8954 | ||||||||||||
| 93 | headerlen = 13 + 1; executed 400 times by 1 test: headerlen = 13 + 1;Executed by:
| 400 | ||||||||||||
| 94 | else | - | ||||||||||||
| 95 | headerlen = 5; executed 8954 times by 1 test: headerlen = 5;Executed by:
| 8954 | ||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | align = (-5) & (8 - 1); | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | - | |||||||||||||
| 101 | len = ssl_get_max_send_fragment(s) | - | ||||||||||||
| 102 | + (16 + 64) + headerlen + align; | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | if (ssl_allow_compression(s)
| 0-9354 | ||||||||||||
| 105 | len += 1024; never executed: len += 1024; | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | if (!(s->options & 0x00000800U)
| 0-9354 | ||||||||||||
| 108 | len += headerlen + align + (16 + 64); executed 9354 times by 1 test: len += headerlen + align + (16 + 64);Executed by:
| 9354 | ||||||||||||
| 109 | } executed 9354 times by 1 test: end of blockExecuted by:
| 9354 | ||||||||||||
| 110 | - | |||||||||||||
| 111 | wb = ((&s->rlayer)->wbuf); | - | ||||||||||||
| 112 | for (currpipe = 0; currpipe < numwpipes
| 9354 | ||||||||||||
| 113 | SSL3_BUFFER *thiswb = &wb[currpipe]; | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | if (thiswb->buf !=
| 1323-8031 | ||||||||||||
| 116 | ((void *)0)
| 1323-8031 | ||||||||||||
| 117 | && thiswb->len != len
| 14-1309 | ||||||||||||
| 118 | CRYPTO_free(thiswb->buf, __FILE__, 115); | - | ||||||||||||
| 119 | thiswb->buf = | - | ||||||||||||
| 120 | ((void *)0) | - | ||||||||||||
| 121 | ; | - | ||||||||||||
| 122 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | if (thiswb->buf ==
| 1309-8045 | ||||||||||||
| 125 | ((void *)0)
| 1309-8045 | ||||||||||||
| 126 | ) { | - | ||||||||||||
| 127 | p = CRYPTO_malloc(len, __FILE__, 120); | - | ||||||||||||
| 128 | if (p ==
| 0-8045 | ||||||||||||
| 129 | ((void *)0)
| 0-8045 | ||||||||||||
| 130 | ) { | - | ||||||||||||
| 131 | s->rlayer.numwpipes = currpipe; | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | ossl_statem_fatal((s), (-1), (291), ((1|64)), | - | ||||||||||||
| 138 | __FILE__ | - | ||||||||||||
| 139 | , | - | ||||||||||||
| 140 | 129 | - | ||||||||||||
| 141 | ) | - | ||||||||||||
| 142 | ; | - | ||||||||||||
| 143 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | memset(thiswb, 0, sizeof(SSL3_BUFFER)); | - | ||||||||||||
| 146 | thiswb->buf = p; | - | ||||||||||||
| 147 | thiswb->len = len; | - | ||||||||||||
| 148 | } executed 8045 times by 1 test: end of blockExecuted by:
| 8045 | ||||||||||||
| 149 | } executed 9354 times by 1 test: end of blockExecuted by:
| 9354 | ||||||||||||
| 150 | - | |||||||||||||
| 151 | return executed 9354 times by 1 test: 1;return 1;Executed by:
executed 9354 times by 1 test: return 1;Executed by:
| 9354 | ||||||||||||
| 152 | } | - | ||||||||||||
| 153 | - | |||||||||||||
| 154 | int ssl3_setup_buffers(SSL *s) | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | if (!ssl3_setup_read_buffer(s)
| 0-9342 | ||||||||||||
| 157 | - | |||||||||||||
| 158 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 159 | } | - | ||||||||||||
| 160 | if (!ssl3_setup_write_buffer(s, 1, 0)
| 0-9342 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | return executed 9342 times by 1 test: 1;return 1;Executed by:
executed 9342 times by 1 test: return 1;Executed by:
| 9342 | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | int ssl3_release_write_buffer(SSL *s) | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | SSL3_BUFFER *wb; | - | ||||||||||||
| 170 | size_t pipes; | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | pipes = s->rlayer.numwpipes; | - | ||||||||||||
| 173 | while (pipes > 0
| 8031-24238 | ||||||||||||
| 174 | wb = &((&s->rlayer)->wbuf)[pipes - 1]; | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | CRYPTO_free(wb->buf, __FILE__, 163); | - | ||||||||||||
| 177 | wb->buf = | - | ||||||||||||
| 178 | ((void *)0) | - | ||||||||||||
| 179 | ; | - | ||||||||||||
| 180 | pipes--; | - | ||||||||||||
| 181 | } executed 8031 times by 1 test: end of blockExecuted by:
| 8031 | ||||||||||||
| 182 | s->rlayer.numwpipes = 0; | - | ||||||||||||
| 183 | return executed 24238 times by 2 tests: 1;return 1;Executed by:
executed 24238 times by 2 tests: return 1;Executed by:
| 24238 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | int ssl3_release_read_buffer(SSL *s) | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | SSL3_BUFFER *b; | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | b = (&(&s->rlayer)->rbuf); | - | ||||||||||||
| 191 | CRYPTO_free(b->buf, __FILE__, 176); | - | ||||||||||||
| 192 | b->buf = | - | ||||||||||||
| 193 | ((void *)0) | - | ||||||||||||
| 194 | ; | - | ||||||||||||
| 195 | return executed 7966 times by 1 test: 1;return 1;Executed by:
executed 7966 times by 1 test: return 1;Executed by:
| 7966 | ||||||||||||
| 196 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |