| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/statem/statem_dtls.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | static unsigned char bitmask_start_values[] = | - | ||||||||||||||||||||||||
| 2 | { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80 }; | - | ||||||||||||||||||||||||
| 3 | static unsigned char bitmask_end_values[] = | - | ||||||||||||||||||||||||
| 4 | { 0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f }; | - | ||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | static void dtls1_fix_message_header(SSL *s, size_t frag_off, | - | ||||||||||||||||||||||||
| 7 | size_t frag_len); | - | ||||||||||||||||||||||||
| 8 | static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p); | - | ||||||||||||||||||||||||
| 9 | static void dtls1_set_message_header_int(SSL *s, unsigned char mt, | - | ||||||||||||||||||||||||
| 10 | size_t len, | - | ||||||||||||||||||||||||
| 11 | unsigned short seq_num, | - | ||||||||||||||||||||||||
| 12 | size_t frag_off, | - | ||||||||||||||||||||||||
| 13 | size_t frag_len); | - | ||||||||||||||||||||||||
| 14 | static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len); | - | ||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | static hm_fragment *dtls1_hm_fragment_new(size_t frag_len, int reassembly) | - | ||||||||||||||||||||||||
| 17 | { | - | ||||||||||||||||||||||||
| 18 | hm_fragment *frag = | - | ||||||||||||||||||||||||
| 19 | ((void *)0) | - | ||||||||||||||||||||||||
| 20 | ; | - | ||||||||||||||||||||||||
| 21 | unsigned char *buf = | - | ||||||||||||||||||||||||
| 22 | ((void *)0) | - | ||||||||||||||||||||||||
| 23 | ; | - | ||||||||||||||||||||||||
| 24 | unsigned char *bitmask = | - | ||||||||||||||||||||||||
| 25 | ((void *)0) | - | ||||||||||||||||||||||||
| 26 | ; | - | ||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | if ((
| 0-2234 | ||||||||||||||||||||||||
| 29 | ((void *)0)
| 0-2234 | ||||||||||||||||||||||||
| 30 | ) { | - | ||||||||||||||||||||||||
| 31 | ERR_put_error(20,(623),((1|64)),__FILE__,63); | - | ||||||||||||||||||||||||
| 32 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 33 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 34 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 35 | } | - | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | if (frag_len
| 9-2225 | ||||||||||||||||||||||||
| 38 | if ((
| 0-2225 | ||||||||||||||||||||||||
| 39 | ((void *)0)
| 0-2225 | ||||||||||||||||||||||||
| 40 | ) { | - | ||||||||||||||||||||||||
| 41 | ERR_put_error(20,(623),((1|64)),__FILE__,69); | - | ||||||||||||||||||||||||
| 42 | CRYPTO_free(frag, __FILE__, 70); | - | ||||||||||||||||||||||||
| 43 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 44 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 45 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 46 | } | - | ||||||||||||||||||||||||
| 47 | } executed 2225 times by 1 test: end of blockExecuted by:
| 2225 | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | frag->fragment = buf; | - | ||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | if (reassembly
| 334-1900 | ||||||||||||||||||||||||
| 54 | bitmask = CRYPTO_zalloc((((frag_len) + 7) / 8), __FILE__, 80); | - | ||||||||||||||||||||||||
| 55 | if (bitmask ==
| 0-334 | ||||||||||||||||||||||||
| 56 | ((void *)0)
| 0-334 | ||||||||||||||||||||||||
| 57 | ) { | - | ||||||||||||||||||||||||
| 58 | ERR_put_error(20,(623),((1|64)),__FILE__,82); | - | ||||||||||||||||||||||||
| 59 | CRYPTO_free(buf, __FILE__, 83); | - | ||||||||||||||||||||||||
| 60 | CRYPTO_free(frag, __FILE__, 84); | - | ||||||||||||||||||||||||
| 61 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 62 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 63 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 64 | } | - | ||||||||||||||||||||||||
| 65 | } executed 334 times by 1 test: end of blockExecuted by:
| 334 | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | frag->reassembly = bitmask; | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | return executed 2234 times by 1 test: frag;return frag;Executed by:
executed 2234 times by 1 test: return frag;Executed by:
| 2234 | ||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | void dtls1_hm_fragment_free(hm_fragment *frag) | - | ||||||||||||||||||||||||
| 73 | { | - | ||||||||||||||||||||||||
| 74 | if (!frag
| 0-2234 | ||||||||||||||||||||||||
| 75 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 76 | if (frag->msg_header.is_ccs
| 359-1875 | ||||||||||||||||||||||||
| 77 | EVP_CIPHER_CTX_free(frag->msg_header. | - | ||||||||||||||||||||||||
| 78 | saved_retransmit_state.enc_write_ctx); | - | ||||||||||||||||||||||||
| 79 | EVP_MD_CTX_free(frag->msg_header.saved_retransmit_state.write_hash); | - | ||||||||||||||||||||||||
| 80 | } executed 359 times by 1 test: end of blockExecuted by:
| 359 | ||||||||||||||||||||||||
| 81 | CRYPTO_free(frag->fragment, __FILE__, 103); | - | ||||||||||||||||||||||||
| 82 | CRYPTO_free(frag->reassembly, __FILE__, 104); | - | ||||||||||||||||||||||||
| 83 | CRYPTO_free(frag, __FILE__, 105); | - | ||||||||||||||||||||||||
| 84 | } executed 2234 times by 1 test: end of blockExecuted by:
| 2234 | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | int dtls1_do_write(SSL *s, int type) | - | ||||||||||||||||||||||||
| 91 | { | - | ||||||||||||||||||||||||
| 92 | int ret; | - | ||||||||||||||||||||||||
| 93 | size_t written; | - | ||||||||||||||||||||||||
| 94 | size_t curr_mtu; | - | ||||||||||||||||||||||||
| 95 | int retry = 1; | - | ||||||||||||||||||||||||
| 96 | size_t len, frag_off, mac_size, blocksize, used_len; | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | if (!dtls1_query_mtu(s)
| 0-2013 | ||||||||||||||||||||||||
| 99 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | if (s->d1->mtu < dtls1_min_mtu(s)
| 0-2013 | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | if (s->init_off == 0
| 0-2013 | ||||||||||||||||||||||||
| 106 | if (!((s->init_num == s->d1->w_msg_hdr.msg_len + 12) != 0)
| 0-1634 | ||||||||||||||||||||||||
| 107 | ) | - | ||||||||||||||||||||||||
| 108 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 109 | } executed 1634 times by 1 test: end of blockExecuted by:
| 1634 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | if (s->write_hash
| 452-1561 | ||||||||||||||||||||||||
| 112 | if (s->enc_write_ctx
| 0-452 | ||||||||||||||||||||||||
| 113 | && (
| 145-307 | ||||||||||||||||||||||||
| 114 | 0x200000) != 0
| 145-307 | ||||||||||||||||||||||||
| 115 | mac_size = 0; executed 307 times by 1 test: mac_size = 0;Executed by:
| 307 | ||||||||||||||||||||||||
| 116 | else | - | ||||||||||||||||||||||||
| 117 | mac_size = EVP_MD_size(EVP_MD_CTX_md(s->write_hash)); executed 145 times by 1 test: mac_size = EVP_MD_size(EVP_MD_CTX_md(s->write_hash));Executed by:
| 145 | ||||||||||||||||||||||||
| 118 | } else | - | ||||||||||||||||||||||||
| 119 | mac_size = 0; executed 1561 times by 1 test: mac_size = 0;Executed by:
| 1561 | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | if (s->enc_write_ctx
| 452-1561 | ||||||||||||||||||||||||
| 122 | ((
| 133-319 | ||||||||||||||||||||||||
| 123 | blocksize = 2 * EVP_CIPHER_CTX_block_size(s->enc_write_ctx); executed 133 times by 1 test: blocksize = 2 * EVP_CIPHER_CTX_block_size(s->enc_write_ctx);Executed by:
| 133 | ||||||||||||||||||||||||
| 124 | else | - | ||||||||||||||||||||||||
| 125 | blocksize = 0; executed 1880 times by 1 test: blocksize = 0;Executed by:
| 1880 | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | frag_off = 0; | - | ||||||||||||||||||||||||
| 128 | s->rwstate = 1; | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | while (s->init_num > 0
| 0-3030 | ||||||||||||||||||||||||
| 132 | if (type == 22
| 379-2651 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | if (frag_off > 0
| 0-1017 | ||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | if (s->init_off <= 12
| 0-1017 | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 147 | } | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | s->init_off -= 12; | - | ||||||||||||||||||||||||
| 154 | s->init_num += 12; | - | ||||||||||||||||||||||||
| 155 | } executed 1017 times by 1 test: else {end of blockExecuted by:
| 1017 | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | frag_off = s->d1->w_msg_hdr.frag_off; | - | ||||||||||||||||||||||||
| 163 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | used_len = (int)BIO_ctrl(s->wbio,13,0, | - | ||||||||||||||||||||||||
| 167 | ((void *)0) | - | ||||||||||||||||||||||||
| 168 | ) + 13 | - | ||||||||||||||||||||||||
| 169 | + mac_size + blocksize; | - | ||||||||||||||||||||||||
| 170 | if (s->d1->mtu > used_len
| 1068-1962 | ||||||||||||||||||||||||
| 171 | curr_mtu = s->d1->mtu - used_len; executed 1962 times by 1 test: curr_mtu = s->d1->mtu - used_len;Executed by:
| 1962 | ||||||||||||||||||||||||
| 172 | else | - | ||||||||||||||||||||||||
| 173 | curr_mtu = 0; executed 1068 times by 1 test: curr_mtu = 0;Executed by:
| 1068 | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | if (curr_mtu <= 12
| 1162-1868 | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | ret = (int)BIO_ctrl(s->wbio,11,0, | - | ||||||||||||||||||||||||
| 180 | ((void *)0) | - | ||||||||||||||||||||||||
| 181 | ); | - | ||||||||||||||||||||||||
| 182 | if (ret <= 0
| 0-1162 | ||||||||||||||||||||||||
| 183 | s->rwstate = 2; | - | ||||||||||||||||||||||||
| 184 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||
| 186 | used_len = 13 + mac_size + blocksize; | - | ||||||||||||||||||||||||
| 187 | if (s->d1->mtu > used_len + 12
| 0-1162 | ||||||||||||||||||||||||
| 188 | curr_mtu = s->d1->mtu - used_len; | - | ||||||||||||||||||||||||
| 189 | } executed 1162 times by 1 test: else {end of blockExecuted by:
| 1162 | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 192 | } | - | ||||||||||||||||||||||||
| 193 | } | - | ||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | if (((
| 1017-2013 | ||||||||||||||||||||||||
| 199 | len = curr_mtu; executed 1017 times by 1 test: len = curr_mtu;Executed by:
| 1017 | ||||||||||||||||||||||||
| 200 | else | - | ||||||||||||||||||||||||
| 201 | len = s->init_num; executed 2013 times by 1 test: len = s->init_num;Executed by:
| 2013 | ||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||
| 203 | if (len > s->max_send_fragment
| 0-3030 | ||||||||||||||||||||||||
| 204 | len = s->max_send_fragment; never executed: len = s->max_send_fragment; | 0 | ||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | if (type == 22
| 379-2651 | ||||||||||||||||||||||||
| 210 | if (len < 12
| 0-2651 | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 216 | } | - | ||||||||||||||||||||||||
| 217 | dtls1_fix_message_header(s, frag_off, len - 12); | - | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | dtls1_write_message_header(s, | - | ||||||||||||||||||||||||
| 220 | (unsigned char *)&s->init_buf-> | - | ||||||||||||||||||||||||
| 221 | data[s->init_off]); | - | ||||||||||||||||||||||||
| 222 | } executed 2651 times by 1 test: end of blockExecuted by:
| 2651 | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | ret = dtls1_write_bytes(s, type, &s->init_buf->data[s->init_off], len, | - | ||||||||||||||||||||||||
| 225 | &written); | - | ||||||||||||||||||||||||
| 226 | if (ret < 0
| 0-3030 | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | if (retry
| 0 | ||||||||||||||||||||||||
| 234 | 43, 0,
| 0 | ||||||||||||||||||||||||
| 235 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 236 | ) > 0
| 0 | ||||||||||||||||||||||||
| 237 | if (!(SSL_get_options(s) & 0x00001000U)
| 0 | ||||||||||||||||||||||||
| 238 | if (!dtls1_query_mtu(s)
| 0 | ||||||||||||||||||||||||
| 239 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | retry = 0; | - | ||||||||||||||||||||||||
| 242 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||
| 243 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 244 | } else { | - | ||||||||||||||||||||||||
| 245 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||
| 247 | } else { | - | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | if (!((len == written) != 0)
| 0-3030 | ||||||||||||||||||||||||
| 254 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | if (type == 22
| 172-2651 | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | unsigned char *p = | - | ||||||||||||||||||||||||
| 262 | (unsigned char *)&s->init_buf->data[s->init_off]; | - | ||||||||||||||||||||||||
| 263 | const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; | - | ||||||||||||||||||||||||
| 264 | size_t xlen; | - | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | if (frag_off == 0
| 3-1532 | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | *p++ = msg_hdr->type; | - | ||||||||||||||||||||||||
| 272 | (((p)[0]=(unsigned char)(((msg_hdr->msg_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_hdr->msg_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_hdr->msg_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 273 | (((p)[0]=(unsigned char)(((msg_hdr->seq)>> 8)&0xff), (p)[1]=(unsigned char)(((msg_hdr->seq) )&0xff)),(p)+=2); | - | ||||||||||||||||||||||||
| 274 | (((p)[0]=(unsigned char)(((0)>>16)&0xff), (p)[1]=(unsigned char)(((0)>> 8)&0xff), (p)[2]=(unsigned char)(((0) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 275 | (((p)[0]=(unsigned char)(((msg_hdr->msg_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_hdr->msg_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_hdr->msg_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 276 | p -= 12; | - | ||||||||||||||||||||||||
| 277 | xlen = written; | - | ||||||||||||||||||||||||
| 278 | } executed 1529 times by 1 test: else {end of blockExecuted by:
| 1529 | ||||||||||||||||||||||||
| 279 | p += 12; | - | ||||||||||||||||||||||||
| 280 | xlen = written - 12; | - | ||||||||||||||||||||||||
| 281 | } executed 950 times by 1 test: end of blockExecuted by:
| 950 | ||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||
| 283 | if (!ssl3_finish_mac(s, p, xlen)
| 0-2479 | ||||||||||||||||||||||||
| 284 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 285 | } executed 2479 times by 1 test: end of blockExecuted by:
| 2479 | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | if (written == s->init_num
| 1017-2013 | ||||||||||||||||||||||||
| 288 | if (s->msg_callback
| 0-2013 | ||||||||||||||||||||||||
| 289 | s->msg_callback(1, s->version, type, s->init_buf->data, never executed: s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 290 | (size_t)(s->init_off + s->init_num), s, never executed: s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 291 | s->msg_callback_arg); never executed: s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | s->init_off = 0; | - | ||||||||||||||||||||||||
| 294 | s->init_num = 0; | - | ||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | return executed 2013 times by 1 test: 1;return 1;Executed by:
executed 2013 times by 1 test: return 1;Executed by:
| 2013 | ||||||||||||||||||||||||
| 297 | } | - | ||||||||||||||||||||||||
| 298 | s->init_off += written; | - | ||||||||||||||||||||||||
| 299 | s->init_num -= written; | - | ||||||||||||||||||||||||
| 300 | written -= 12; | - | ||||||||||||||||||||||||
| 301 | frag_off += written; | - | ||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | dtls1_fix_message_header(s, frag_off, 0); | - | ||||||||||||||||||||||||
| 310 | } executed 1017 times by 1 test: end of blockExecuted by:
| 1017 | ||||||||||||||||||||||||
| 311 | } | - | ||||||||||||||||||||||||
| 312 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 313 | } | - | ||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | int dtls_get_message(SSL *s, int *mt, size_t *len) | - | ||||||||||||||||||||||||
| 316 | { | - | ||||||||||||||||||||||||
| 317 | struct hm_header_st *msg_hdr; | - | ||||||||||||||||||||||||
| 318 | unsigned char *p; | - | ||||||||||||||||||||||||
| 319 | size_t msg_len; | - | ||||||||||||||||||||||||
| 320 | size_t tmplen; | - | ||||||||||||||||||||||||
| 321 | int errtype; | - | ||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | msg_hdr = &s->d1->r_msg_hdr; | - | ||||||||||||||||||||||||
| 324 | memset(msg_hdr, 0, sizeof(*msg_hdr)); | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | again: code before this statement executed 2843 times by 1 test: again:Executed by:
| 2843 | ||||||||||||||||||||||||
| 327 | if (!dtls_get_reassembled_message(s, &errtype, &tmplen)
| 1868-2369 | ||||||||||||||||||||||||
| 328 | if (errtype == -2
| 0-2369 | ||||||||||||||||||||||||
| 329 | || errtype == -3
| 975-1394 | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | goto executed 1394 times by 1 test: again;goto again;Executed by:
executed 1394 times by 1 test: goto again;Executed by:
| 1394 | ||||||||||||||||||||||||
| 332 | } | - | ||||||||||||||||||||||||
| 333 | return executed 975 times by 1 test: 0;return 0;Executed by:
executed 975 times by 1 test: return 0;Executed by:
| 975 | ||||||||||||||||||||||||
| 334 | } | - | ||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | *mt = s->s3->tmp.message_type; | - | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | p = (unsigned char *)s->init_buf->data; | - | ||||||||||||||||||||||||
| 339 | *len = s->init_num; | - | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | if (*
| 358-1510 | ||||||||||||||||||||||||
| 342 | if (s->msg_callback
| 0-358 | ||||||||||||||||||||||||
| 343 | s->msg_callback(0, s->version, 20, | - | ||||||||||||||||||||||||
| 344 | p, 1, s, s->msg_callback_arg); | - | ||||||||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | return executed 358 times by 1 test: 1;return 1;Executed by:
executed 358 times by 1 test: return 1;Executed by:
| 358 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | msg_len = msg_hdr->msg_len; | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | *(p++) = msg_hdr->type; | - | ||||||||||||||||||||||||
| 356 | (((p)[0]=(unsigned char)(((msg_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 357 | (((p)[0]=(unsigned char)(((msg_hdr->seq)>> 8)&0xff), (p)[1]=(unsigned char)(((msg_hdr->seq) )&0xff)),(p)+=2); | - | ||||||||||||||||||||||||
| 358 | (((p)[0]=(unsigned char)(((0)>>16)&0xff), (p)[1]=(unsigned char)(((0)>> 8)&0xff), (p)[2]=(unsigned char)(((0) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 359 | (((p)[0]=(unsigned char)(((msg_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 360 | if (s->version != 0x0100
| 3-1507 | ||||||||||||||||||||||||
| 361 | p -= 12; | - | ||||||||||||||||||||||||
| 362 | msg_len += 12; | - | ||||||||||||||||||||||||
| 363 | } executed 1507 times by 1 test: end of blockExecuted by:
| 1507 | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | if (*
| 0-1155 | ||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 372 | } | - | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | if (!ssl3_finish_mac(s, p, msg_len)
| 0-1510 | ||||||||||||||||||||||||
| 375 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 376 | if (s->msg_callback
| 0-1510 | ||||||||||||||||||||||||
| 377 | s->msg_callback(0, s->version, 22, never executed: s->msg_callback(0, s->version, 22, p, msg_len, s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 378 | p, msg_len, s, s->msg_callback_arg); never executed: s->msg_callback(0, s->version, 22, p, msg_len, s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | memset(msg_hdr, 0, sizeof(*msg_hdr)); | - | ||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||
| 382 | s->d1->handshake_read_seq++; | - | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | s->init_msg = s->init_buf->data + 12; | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | return executed 1510 times by 1 test: 1;return 1;Executed by:
executed 1510 times by 1 test: return 1;Executed by:
| 1510 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | static size_t dtls1_max_handshake_message_len(const SSL *s) | - | ||||||||||||||||||||||||
| 395 | { | - | ||||||||||||||||||||||||
| 396 | size_t max_len = 12 + ((256 + 64)+(16384 +1024)); | - | ||||||||||||||||||||||||
| 397 | if (max_len < s->max_cert_list
| 0-2793 | ||||||||||||||||||||||||
| 398 | return executed 2793 times by 1 test: s->max_cert_list;return s->max_cert_list;Executed by:
executed 2793 times by 1 test: return s->max_cert_list;Executed by:
| 2793 | ||||||||||||||||||||||||
| 399 | return never executed: max_len;return max_len;never executed: return max_len; | 0 | ||||||||||||||||||||||||
| 400 | } | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr) | - | ||||||||||||||||||||||||
| 403 | { | - | ||||||||||||||||||||||||
| 404 | size_t frag_off, frag_len, msg_len; | - | ||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | msg_len = msg_hdr->msg_len; | - | ||||||||||||||||||||||||
| 407 | frag_off = msg_hdr->frag_off; | - | ||||||||||||||||||||||||
| 408 | frag_len = msg_hdr->frag_len; | - | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||
| 411 | if ((
| 0-1510 | ||||||||||||||||||||||||
| 412 | || msg_len > dtls1_max_handshake_message_len(s)
| 0-1510 | ||||||||||||||||||||||||
| 413 | ossl_statem_fatal((s), (47), (288), (152), | - | ||||||||||||||||||||||||
| 414 | __FILE__ | - | ||||||||||||||||||||||||
| 415 | , | - | ||||||||||||||||||||||||
| 416 | 430 | - | ||||||||||||||||||||||||
| 417 | ) | - | ||||||||||||||||||||||||
| 418 | ; | - | ||||||||||||||||||||||||
| 419 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 420 | } | - | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | if (s->d1->r_msg_hdr.frag_off == 0
| 0-1510 | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | if (!BUF_MEM_grow_clean(s->init_buf, msg_len + 12)
| 0-1510 | ||||||||||||||||||||||||
| 428 | ossl_statem_fatal((s), (80), (288), (7), | - | ||||||||||||||||||||||||
| 429 | __FILE__ | - | ||||||||||||||||||||||||
| 430 | , | - | ||||||||||||||||||||||||
| 431 | 441 | - | ||||||||||||||||||||||||
| 432 | ) | - | ||||||||||||||||||||||||
| 433 | ; | - | ||||||||||||||||||||||||
| 434 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 435 | } | - | ||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | s->s3->tmp.message_size = msg_len; | - | ||||||||||||||||||||||||
| 438 | s->d1->r_msg_hdr.msg_len = msg_len; | - | ||||||||||||||||||||||||
| 439 | s->s3->tmp.message_type = msg_hdr->type; | - | ||||||||||||||||||||||||
| 440 | s->d1->r_msg_hdr.type = msg_hdr->type; | - | ||||||||||||||||||||||||
| 441 | s->d1->r_msg_hdr.seq = msg_hdr->seq; | - | ||||||||||||||||||||||||
| 442 | } executed 1510 times by 1 test: else if (msg_len != s->d1->r_msg_hdr.msg_lenend of blockExecuted by:
| 0-1510 | ||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | ossl_statem_fatal((s), (47), (288), (152), | - | ||||||||||||||||||||||||
| 448 | __FILE__ | - | ||||||||||||||||||||||||
| 449 | , | - | ||||||||||||||||||||||||
| 450 | 456 | - | ||||||||||||||||||||||||
| 451 | ) | - | ||||||||||||||||||||||||
| 452 | ; | - | ||||||||||||||||||||||||
| 453 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 454 | } | - | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | return executed 1510 times by 1 test: 1;return 1;Executed by:
executed 1510 times by 1 test: return 1;Executed by:
| 1510 | ||||||||||||||||||||||||
| 457 | } | - | ||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | static int dtls1_retrieve_buffered_fragment(SSL *s, size_t *len) | - | ||||||||||||||||||||||||
| 464 | { | - | ||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | pitem *item; | - | ||||||||||||||||||||||||
| 472 | hm_fragment *frag; | - | ||||||||||||||||||||||||
| 473 | int ret; | - | ||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | do { | - | ||||||||||||||||||||||||
| 476 | item = pqueue_peek(s->d1->buffered_messages); | - | ||||||||||||||||||||||||
| 477 | if (item ==
| 1431-2806 | ||||||||||||||||||||||||
| 478 | ((void *)0)
| 1431-2806 | ||||||||||||||||||||||||
| 479 | ) | - | ||||||||||||||||||||||||
| 480 | return executed 2806 times by 1 test: 0;return 0;Executed by:
executed 2806 times by 1 test: return 0;Executed by:
| 2806 | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | frag = (hm_fragment *)item->data; | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | if (frag->msg_header.seq < s->d1->handshake_read_seq
| 0-1431 | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | pqueue_pop(s->d1->buffered_messages); | - | ||||||||||||||||||||||||
| 487 | dtls1_hm_fragment_free(frag); | - | ||||||||||||||||||||||||
| 488 | pitem_free(item); | - | ||||||||||||||||||||||||
| 489 | item = | - | ||||||||||||||||||||||||
| 490 | ((void *)0) | - | ||||||||||||||||||||||||
| 491 | ; | - | ||||||||||||||||||||||||
| 492 | frag = | - | ||||||||||||||||||||||||
| 493 | ((void *)0) | - | ||||||||||||||||||||||||
| 494 | ; | - | ||||||||||||||||||||||||
| 495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 496 | } executed 1431 times by 1 test: while (item == end of blockExecuted by:
| 0-1431 | ||||||||||||||||||||||||
| 497 | ((void *)0)
| 0-1431 | ||||||||||||||||||||||||
| 498 | ); | - | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||
| 501 | if (frag->reassembly !=
| 358-1073 | ||||||||||||||||||||||||
| 502 | ((void *)0)
| 358-1073 | ||||||||||||||||||||||||
| 503 | ) | - | ||||||||||||||||||||||||
| 504 | return executed 1073 times by 1 test: 0;return 0;Executed by:
executed 1073 times by 1 test: return 0;Executed by:
| 1073 | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | if (s->d1->handshake_read_seq == frag->msg_header.seq
| 15-343 | ||||||||||||||||||||||||
| 507 | size_t frag_len = frag->msg_header.frag_len; | - | ||||||||||||||||||||||||
| 508 | pqueue_pop(s->d1->buffered_messages); | - | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||
| 511 | ret = dtls1_preprocess_fragment(s, &frag->msg_header); | - | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | if (ret
| 0-343 | ||||||||||||||||||||||||
| 514 | unsigned char *p = | - | ||||||||||||||||||||||||
| 515 | (unsigned char *)s->init_buf->data + 12; | - | ||||||||||||||||||||||||
| 516 | memcpy(&p[frag->msg_header.frag_off], frag->fragment, | - | ||||||||||||||||||||||||
| 517 | frag->msg_header.frag_len); | - | ||||||||||||||||||||||||
| 518 | } executed 334 times by 1 test: end of blockExecuted by:
| 334 | ||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | dtls1_hm_fragment_free(frag); | - | ||||||||||||||||||||||||
| 521 | pitem_free(item); | - | ||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | if (ret
| 0-343 | ||||||||||||||||||||||||
| 524 | *len = frag_len; | - | ||||||||||||||||||||||||
| 525 | return executed 343 times by 1 test: 1;return 1;Executed by:
executed 343 times by 1 test: return 1;Executed by:
| 343 | ||||||||||||||||||||||||
| 526 | } | - | ||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||
| 529 | s->init_num = 0; | - | ||||||||||||||||||||||||
| 530 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 531 | } else { | - | ||||||||||||||||||||||||
| 532 | return executed 15 times by 1 test: 0;return 0;Executed by:
executed 15 times by 1 test: return 0;Executed by:
| 15 | ||||||||||||||||||||||||
| 533 | } | - | ||||||||||||||||||||||||
| 534 | } | - | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | static int | - | ||||||||||||||||||||||||
| 537 | dtls1_reassemble_fragment(SSL *s, const struct hm_header_st *msg_hdr) | - | ||||||||||||||||||||||||
| 538 | { | - | ||||||||||||||||||||||||
| 539 | hm_fragment *frag = | - | ||||||||||||||||||||||||
| 540 | ((void *)0) | - | ||||||||||||||||||||||||
| 541 | ; | - | ||||||||||||||||||||||||
| 542 | pitem *item = | - | ||||||||||||||||||||||||
| 543 | ((void *)0) | - | ||||||||||||||||||||||||
| 544 | ; | - | ||||||||||||||||||||||||
| 545 | int i = -1, is_complete; | - | ||||||||||||||||||||||||
| 546 | unsigned char seq64be[8]; | - | ||||||||||||||||||||||||
| 547 | size_t frag_len = msg_hdr->frag_len; | - | ||||||||||||||||||||||||
| 548 | size_t readbytes; | - | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | if ((
| 0-1274 | ||||||||||||||||||||||||
| 551 | msg_hdr->msg_len > dtls1_max_handshake_message_len(s)
| 0-1274 | ||||||||||||||||||||||||
| 552 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | if (frag_len == 0
| 0-1274 | ||||||||||||||||||||||||
| 555 | return never executed: -3;return -3;never executed: return -3; | 0 | ||||||||||||||||||||||||
| 556 | } | - | ||||||||||||||||||||||||
| 557 | - | |||||||||||||||||||||||||
| 558 | - | |||||||||||||||||||||||||
| 559 | memset(seq64be, 0, sizeof(seq64be)); | - | ||||||||||||||||||||||||
| 560 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); | - | ||||||||||||||||||||||||
| 561 | seq64be[7] = (unsigned char)msg_hdr->seq; | - | ||||||||||||||||||||||||
| 562 | item = pqueue_find(s->d1->buffered_messages, seq64be); | - | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | if (item ==
| 334-940 | ||||||||||||||||||||||||
| 565 | ((void *)0)
| 334-940 | ||||||||||||||||||||||||
| 566 | ) { | - | ||||||||||||||||||||||||
| 567 | frag = dtls1_hm_fragment_new(msg_hdr->msg_len, 1); | - | ||||||||||||||||||||||||
| 568 | if (frag ==
| 0-334 | ||||||||||||||||||||||||
| 569 | ((void *)0)
| 0-334 | ||||||||||||||||||||||||
| 570 | ) | - | ||||||||||||||||||||||||
| 571 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 572 | memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); | - | ||||||||||||||||||||||||
| 573 | frag->msg_header.frag_len = frag->msg_header.msg_len; | - | ||||||||||||||||||||||||
| 574 | frag->msg_header.frag_off = 0; | - | ||||||||||||||||||||||||
| 575 | } executed 334 times by 1 test: else {end of blockExecuted by:
| 334 | ||||||||||||||||||||||||
| 576 | frag = (hm_fragment *)item->data; | - | ||||||||||||||||||||||||
| 577 | if (frag->msg_header.msg_len != msg_hdr->msg_len
| 0-940 | ||||||||||||||||||||||||
| 578 | item = | - | ||||||||||||||||||||||||
| 579 | ((void *)0) | - | ||||||||||||||||||||||||
| 580 | ; | - | ||||||||||||||||||||||||
| 581 | frag = | - | ||||||||||||||||||||||||
| 582 | ((void *)0) | - | ||||||||||||||||||||||||
| 583 | ; | - | ||||||||||||||||||||||||
| 584 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||
| 586 | } executed 940 times by 1 test: end of blockExecuted by:
| 940 | ||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||
| 593 | if (frag->reassembly ==
| 0-1274 | ||||||||||||||||||||||||
| 594 | ((void *)0)
| 0-1274 | ||||||||||||||||||||||||
| 595 | ) { | - | ||||||||||||||||||||||||
| 596 | unsigned char devnull[256]; | - | ||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||
| 598 | while (frag_len
| 0 | ||||||||||||||||||||||||
| 599 | i = s->method->ssl_read_bytes(s, 22, | - | ||||||||||||||||||||||||
| 600 | ((void *)0) | - | ||||||||||||||||||||||||
| 601 | , | - | ||||||||||||||||||||||||
| 602 | devnull, | - | ||||||||||||||||||||||||
| 603 | frag_len > | - | ||||||||||||||||||||||||
| 604 | sizeof(devnull) ? sizeof(devnull) : | - | ||||||||||||||||||||||||
| 605 | frag_len, 0, &readbytes); | - | ||||||||||||||||||||||||
| 606 | if (i <= 0
| 0 | ||||||||||||||||||||||||
| 607 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 608 | frag_len -= readbytes; | - | ||||||||||||||||||||||||
| 609 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 610 | return never executed: -3;return -3;never executed: return -3; | 0 | ||||||||||||||||||||||||
| 611 | } | - | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | - | |||||||||||||||||||||||||
| 614 | i = s->method->ssl_read_bytes(s, 22, | - | ||||||||||||||||||||||||
| 615 | ((void *)0) | - | ||||||||||||||||||||||||
| 616 | , | - | ||||||||||||||||||||||||
| 617 | frag->fragment + msg_hdr->frag_off, | - | ||||||||||||||||||||||||
| 618 | frag_len, 0, &readbytes); | - | ||||||||||||||||||||||||
| 619 | if (i <= 0
| 0-1274 | ||||||||||||||||||||||||
| 620 | i = -1; never executed: i = -1; | 0 | ||||||||||||||||||||||||
| 621 | if (i <= 0
| 0-1274 | ||||||||||||||||||||||||
| 622 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | { if (((
executed 91 times by 1 test: }frag->reassembly[((ii) >> 3)] |= (1 << ((ii) & 7));Executed by:
executed 24 times by 1 test: else { long ii; frag->reassembly[(((long)msg_hdr->frag_off) >> 3)] |= bitmask_start_values[(((long)msg_hdr->frag_off) & 7)]; for (ii = ((((long)msg_hdr->frag_off) >> 3) + 1); ii < (((((long)(msg_hdr->frag_off + frag_len)) - 1)) >> 3)end of blockExecuted by:
executed 27354 times by 1 test: frag->reassembly[((((long)(msg_hdr->frag_off + frag_len)) - 1) >> 3)] |= bitmask_end_values[(((long)(msg_hdr->frag_off + frag_len)) & 7)]; }frag->reassembly[ii] = 0xff;Executed by:
executed 1250 times by 1 test: }end of blockExecuted by:
| 24-27354 | ||||||||||||||||||||||||
| 625 | ; | - | ||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | if (!((msg_hdr->msg_len > 0) != 0)
| 0-1274 | ||||||||||||||||||||||||
| 628 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 629 | { long ii; is_complete = 1; if (frag->reassembly[((((long)msg_hdr->msg_len) - 1) >> 3)] != bitmask_end_values[(((long)msg_hdr->msg_len) & 7)]
executed 926 times by 1 test: if (is_completeis_complete = 0;Executed by:
executed 14 times by 1 test: } }break;Executed by:
| 14-28919 | ||||||||||||||||||||||||
| 630 | ; | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | if (is_complete
| 334-940 | ||||||||||||||||||||||||
| 633 | CRYPTO_free(frag->reassembly, __FILE__, 609); | - | ||||||||||||||||||||||||
| 634 | frag->reassembly = | - | ||||||||||||||||||||||||
| 635 | ((void *)0) | - | ||||||||||||||||||||||||
| 636 | ; | - | ||||||||||||||||||||||||
| 637 | } executed 334 times by 1 test: end of blockExecuted by:
| 334 | ||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||
| 639 | if (item ==
| 334-940 | ||||||||||||||||||||||||
| 640 | ((void *)0)
| 334-940 | ||||||||||||||||||||||||
| 641 | ) { | - | ||||||||||||||||||||||||
| 642 | item = pitem_new(seq64be, frag); | - | ||||||||||||||||||||||||
| 643 | if (item ==
| 0-334 | ||||||||||||||||||||||||
| 644 | ((void *)0)
| 0-334 | ||||||||||||||||||||||||
| 645 | ) { | - | ||||||||||||||||||||||||
| 646 | i = -1; | - | ||||||||||||||||||||||||
| 647 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | item = pqueue_insert(s->d1->buffered_messages, item); | - | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | - | |||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||
| 657 | if (!((item !=
| 0-334 | ||||||||||||||||||||||||
| 658 | ((void *)0)
| 0-334 | ||||||||||||||||||||||||
| 659 | ) != 0)
| 0-334 | ||||||||||||||||||||||||
| 660 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 661 | } executed 334 times by 1 test: end of blockExecuted by:
| 334 | ||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | return executed 1274 times by 1 test: -3;return -3;Executed by:
executed 1274 times by 1 test: return -3;Executed by:
| 1274 | ||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | err: | - | ||||||||||||||||||||||||
| 666 | if (item ==
| 0 | ||||||||||||||||||||||||
| 667 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 668 | ) | - | ||||||||||||||||||||||||
| 669 | dtls1_hm_fragment_free(frag); never executed: dtls1_hm_fragment_free(frag); | 0 | ||||||||||||||||||||||||
| 670 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 671 | } | - | ||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||
| 673 | static int | - | ||||||||||||||||||||||||
| 674 | dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr) | - | ||||||||||||||||||||||||
| 675 | { | - | ||||||||||||||||||||||||
| 676 | int i = -1; | - | ||||||||||||||||||||||||
| 677 | hm_fragment *frag = | - | ||||||||||||||||||||||||
| 678 | ((void *)0) | - | ||||||||||||||||||||||||
| 679 | ; | - | ||||||||||||||||||||||||
| 680 | pitem *item = | - | ||||||||||||||||||||||||
| 681 | ((void *)0) | - | ||||||||||||||||||||||||
| 682 | ; | - | ||||||||||||||||||||||||
| 683 | unsigned char seq64be[8]; | - | ||||||||||||||||||||||||
| 684 | size_t frag_len = msg_hdr->frag_len; | - | ||||||||||||||||||||||||
| 685 | size_t readbytes; | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | if ((
| 0-143 | ||||||||||||||||||||||||
| 688 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | memset(seq64be, 0, sizeof(seq64be)); | - | ||||||||||||||||||||||||
| 692 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); | - | ||||||||||||||||||||||||
| 693 | seq64be[7] = (unsigned char)msg_hdr->seq; | - | ||||||||||||||||||||||||
| 694 | item = pqueue_find(s->d1->buffered_messages, seq64be); | - | ||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | if (item !=
| 16-127 | ||||||||||||||||||||||||
| 701 | ((void *)0)
| 16-127 | ||||||||||||||||||||||||
| 702 | && frag_len != msg_hdr->msg_len
| 0-16 | ||||||||||||||||||||||||
| 703 | item = executed 16 times by 1 test: item = ((void *)0) ;Executed by:
| 16 | ||||||||||||||||||||||||
| 704 | ((void *)0) executed 16 times by 1 test: item = ((void *)0) ;Executed by:
| 16 | ||||||||||||||||||||||||
| 705 | ; executed 16 times by 1 test: item = ((void *)0) ;Executed by:
| 16 | ||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||
| 712 | if (msg_hdr->seq <= s->d1->handshake_read_seq
| 32-111 | ||||||||||||||||||||||||
| 713 | msg_hdr->seq > s->d1->handshake_read_seq + 10
| 0-32 | ||||||||||||||||||||||||
| 714 | ((void *)0)
| 0-32 | ||||||||||||||||||||||||
| 715 | || | - | ||||||||||||||||||||||||
| 716 | (s->d1->handshake_read_seq == 0
| 0-23 | ||||||||||||||||||||||||
| 717 | unsigned char devnull[256]; | - | ||||||||||||||||||||||||
| 718 | - | |||||||||||||||||||||||||
| 719 | while (frag_len
| 99-111 | ||||||||||||||||||||||||
| 720 | i = s->method->ssl_read_bytes(s, 22, | - | ||||||||||||||||||||||||
| 721 | ((void *)0) | - | ||||||||||||||||||||||||
| 722 | , | - | ||||||||||||||||||||||||
| 723 | devnull, | - | ||||||||||||||||||||||||
| 724 | frag_len > | - | ||||||||||||||||||||||||
| 725 | sizeof(devnull) ? sizeof(devnull) : | - | ||||||||||||||||||||||||
| 726 | frag_len, 0, &readbytes); | - | ||||||||||||||||||||||||
| 727 | if (i <= 0
| 0-99 | ||||||||||||||||||||||||
| 728 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 729 | frag_len -= readbytes; | - | ||||||||||||||||||||||||
| 730 | } executed 99 times by 1 test: end of blockExecuted by:
| 99 | ||||||||||||||||||||||||
| 731 | } executed 111 times by 1 test: else {end of blockExecuted by:
| 111 | ||||||||||||||||||||||||
| 732 | if (frag_len != msg_hdr->msg_len
| 9-23 | ||||||||||||||||||||||||
| 733 | return executed 23 times by 1 test: dtls1_reassemble_fragment(s, msg_hdr);return dtls1_reassemble_fragment(s, msg_hdr);Executed by:
executed 23 times by 1 test: return dtls1_reassemble_fragment(s, msg_hdr);Executed by:
| 23 | ||||||||||||||||||||||||
| 734 | } | - | ||||||||||||||||||||||||
| 735 | - | |||||||||||||||||||||||||
| 736 | if (frag_len > dtls1_max_handshake_message_len(s)
| 0-9 | ||||||||||||||||||||||||
| 737 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||
| 739 | frag = dtls1_hm_fragment_new(frag_len, 0); | - | ||||||||||||||||||||||||
| 740 | if (frag ==
| 0-9 | ||||||||||||||||||||||||
| 741 | ((void *)0)
| 0-9 | ||||||||||||||||||||||||
| 742 | ) | - | ||||||||||||||||||||||||
| 743 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); | - | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | if (frag_len
| 0-9 | ||||||||||||||||||||||||
| 748 | - | |||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | i = s->method->ssl_read_bytes(s, 22, | - | ||||||||||||||||||||||||
| 752 | ((void *)0) | - | ||||||||||||||||||||||||
| 753 | , | - | ||||||||||||||||||||||||
| 754 | frag->fragment, frag_len, 0, | - | ||||||||||||||||||||||||
| 755 | &readbytes); | - | ||||||||||||||||||||||||
| 756 | if (i<=0
| 0 | ||||||||||||||||||||||||
| 757 | i = -1; never executed: i = -1; | 0 | ||||||||||||||||||||||||
| 758 | if (i <= 0
| 0 | ||||||||||||||||||||||||
| 759 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | item = pitem_new(seq64be, frag); | - | ||||||||||||||||||||||||
| 763 | if (item ==
| 0-9 | ||||||||||||||||||||||||
| 764 | ((void *)0)
| 0-9 | ||||||||||||||||||||||||
| 765 | ) | - | ||||||||||||||||||||||||
| 766 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||
| 768 | item = pqueue_insert(s->d1->buffered_messages, item); | - | ||||||||||||||||||||||||
| 769 | if (!((item !=
| 0-9 | ||||||||||||||||||||||||
| 770 | ((void *)0)
| 0-9 | ||||||||||||||||||||||||
| 771 | ) != 0)
| 0-9 | ||||||||||||||||||||||||
| 772 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 773 | } executed 9 times by 1 test: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||
| 774 | - | |||||||||||||||||||||||||
| 775 | return executed 120 times by 1 test: -3;return -3;Executed by:
executed 120 times by 1 test: return -3;Executed by:
| 120 | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | err: | - | ||||||||||||||||||||||||
| 778 | if (item ==
| 0 | ||||||||||||||||||||||||
| 779 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 780 | ) | - | ||||||||||||||||||||||||
| 781 | dtls1_hm_fragment_free(frag); never executed: dtls1_hm_fragment_free(frag); | 0 | ||||||||||||||||||||||||
| 782 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 783 | } | - | ||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||
| 785 | static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) | - | ||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||
| 787 | unsigned char wire[12]; | - | ||||||||||||||||||||||||
| 788 | size_t mlen, frag_off, frag_len; | - | ||||||||||||||||||||||||
| 789 | int i, ret, recvd_type; | - | ||||||||||||||||||||||||
| 790 | struct hm_header_st msg_hdr; | - | ||||||||||||||||||||||||
| 791 | size_t readbytes; | - | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | *errtype = 0; | - | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | redo: code before this statement executed 4237 times by 1 test: redo:Executed by:
| 4237 | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | ret = dtls1_retrieve_buffered_fragment(s, &frag_len); | - | ||||||||||||||||||||||||
| 798 | if (ret < 0
| 0-4237 | ||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 801 | } | - | ||||||||||||||||||||||||
| 802 | if (ret > 0
| 343-3894 | ||||||||||||||||||||||||
| 803 | s->init_num = frag_len; | - | ||||||||||||||||||||||||
| 804 | *len = frag_len; | - | ||||||||||||||||||||||||
| 805 | return executed 343 times by 1 test: 1;return 1;Executed by:
executed 343 times by 1 test: return 1;Executed by:
| 343 | ||||||||||||||||||||||||
| 806 | } | - | ||||||||||||||||||||||||
| 807 | - | |||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | i = s->method->ssl_read_bytes(s, 22, &recvd_type, wire, | - | ||||||||||||||||||||||||
| 810 | 12, 0, &readbytes); | - | ||||||||||||||||||||||||
| 811 | if (i <= 0
| 975-2919 | ||||||||||||||||||||||||
| 812 | s->rwstate = 3; | - | ||||||||||||||||||||||||
| 813 | *len = 0; | - | ||||||||||||||||||||||||
| 814 | return executed 975 times by 1 test: 0;return 0;Executed by:
executed 975 times by 1 test: return 0;Executed by:
| 975 | ||||||||||||||||||||||||
| 815 | } | - | ||||||||||||||||||||||||
| 816 | if (recvd_type == 20
| 358-2561 | ||||||||||||||||||||||||
| 817 | if (wire[0] != 1
| 0-358 | ||||||||||||||||||||||||
| 818 | ossl_statem_fatal((s), (10), (370), (103), | - | ||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||
| 820 | __FILE__ | - | ||||||||||||||||||||||||
| 821 | , | - | ||||||||||||||||||||||||
| 822 | - | |||||||||||||||||||||||||
| 823 | 772 | - | ||||||||||||||||||||||||
| 824 | ) | - | ||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||
| 826 | ; | - | ||||||||||||||||||||||||
| 827 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 828 | } | - | ||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | memcpy(s->init_buf->data, wire, readbytes); | - | ||||||||||||||||||||||||
| 831 | s->init_num = readbytes - 1; | - | ||||||||||||||||||||||||
| 832 | s->init_msg = s->init_buf->data + 1; | - | ||||||||||||||||||||||||
| 833 | s->s3->tmp.message_type = 0x0101; | - | ||||||||||||||||||||||||
| 834 | s->s3->tmp.message_size = readbytes - 1; | - | ||||||||||||||||||||||||
| 835 | *len = readbytes - 1; | - | ||||||||||||||||||||||||
| 836 | return executed 358 times by 1 test: 1;return 1;Executed by:
executed 358 times by 1 test: return 1;Executed by:
| 358 | ||||||||||||||||||||||||
| 837 | } | - | ||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | if (readbytes != 12
| 0-2561 | ||||||||||||||||||||||||
| 841 | ossl_statem_fatal((s), (10), (370), (244), | - | ||||||||||||||||||||||||
| 842 | __FILE__ | - | ||||||||||||||||||||||||
| 843 | , | - | ||||||||||||||||||||||||
| 844 | 788 | - | ||||||||||||||||||||||||
| 845 | ) | - | ||||||||||||||||||||||||
| 846 | ; | - | ||||||||||||||||||||||||
| 847 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||
| 851 | dtls1_get_message_header(wire, &msg_hdr); | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | mlen = msg_hdr.msg_len; | - | ||||||||||||||||||||||||
| 854 | frag_off = msg_hdr.frag_off; | - | ||||||||||||||||||||||||
| 855 | frag_len = msg_hdr.frag_len; | - | ||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | if (frag_len > RECORD_LAYER_get_rrec_length(&s->rlayer)
| 0-2561 | ||||||||||||||||||||||||
| 862 | ossl_statem_fatal((s), (47), (370), (271), | - | ||||||||||||||||||||||||
| 863 | __FILE__ | - | ||||||||||||||||||||||||
| 864 | , | - | ||||||||||||||||||||||||
| 865 | 805 | - | ||||||||||||||||||||||||
| 866 | ) | - | ||||||||||||||||||||||||
| 867 | ; | - | ||||||||||||||||||||||||
| 868 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 869 | } | - | ||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||
| 877 | if (msg_hdr.seq != s->d1->handshake_read_seq
| 143-2418 | ||||||||||||||||||||||||
| 878 | *errtype = dtls1_process_out_of_seq_message(s, &msg_hdr); | - | ||||||||||||||||||||||||
| 879 | return executed 143 times by 1 test: 0;return 0;Executed by:
executed 143 times by 1 test: return 0;Executed by:
| 143 | ||||||||||||||||||||||||
| 880 | } | - | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | if (frag_len
| 160-2258 | ||||||||||||||||||||||||
| 883 | *errtype = dtls1_reassemble_fragment(s, &msg_hdr); | - | ||||||||||||||||||||||||
| 884 | return executed 1251 times by 1 test: 0;return 0;Executed by:
executed 1251 times by 1 test: return 0;Executed by:
| 1251 | ||||||||||||||||||||||||
| 885 | } | - | ||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | if (!s->server
| 499-668 | ||||||||||||||||||||||||
| 888 | && s->d1->r_msg_hdr.frag_off == 0
| 0-668 | ||||||||||||||||||||||||
| 889 | && s->statem.hand_state != TLS_ST_OK
| 3-665 | ||||||||||||||||||||||||
| 890 | && wire[0] == 0
| 0-665 | ||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | - | |||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||
| 896 | if (wire[1] == 0
| 0 | ||||||||||||||||||||||||
| 897 | if (s->msg_callback
| 0 | ||||||||||||||||||||||||
| 898 | s->msg_callback(0, s->version, 22, never executed: s->msg_callback(0, s->version, 22, wire, 12, s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 899 | wire, 12, s, never executed: s->msg_callback(0, s->version, 22, wire, 12, s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 900 | s->msg_callback_arg); never executed: s->msg_callback(0, s->version, 22, wire, 12, s, s->msg_callback_arg); | 0 | ||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | s->init_num = 0; | - | ||||||||||||||||||||||||
| 903 | goto never executed: redo;goto redo;never executed: goto redo; | 0 | ||||||||||||||||||||||||
| 904 | } else { | - | ||||||||||||||||||||||||
| 905 | - | |||||||||||||||||||||||||
| 906 | ossl_statem_fatal((s), (10), (370), (244), | - | ||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||
| 908 | __FILE__ | - | ||||||||||||||||||||||||
| 909 | , | - | ||||||||||||||||||||||||
| 910 | - | |||||||||||||||||||||||||
| 911 | 846 | - | ||||||||||||||||||||||||
| 912 | ) | - | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | ; | - | ||||||||||||||||||||||||
| 915 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 916 | } | - | ||||||||||||||||||||||||
| 917 | } | - | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | if (!dtls1_preprocess_fragment(s, &msg_hdr)
| 0-1167 | ||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 922 | } | - | ||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||
| 924 | if (frag_len > 0
| 160-1007 | ||||||||||||||||||||||||
| 925 | unsigned char *p = | - | ||||||||||||||||||||||||
| 926 | (unsigned char *)s->init_buf->data + 12; | - | ||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | i = s->method->ssl_read_bytes(s, 22, | - | ||||||||||||||||||||||||
| 929 | ((void *)0) | - | ||||||||||||||||||||||||
| 930 | , | - | ||||||||||||||||||||||||
| 931 | &p[frag_off], frag_len, 0, &readbytes); | - | ||||||||||||||||||||||||
| 932 | - | |||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | if (i <= 0
| 0-1007 | ||||||||||||||||||||||||
| 938 | s->rwstate = 3; | - | ||||||||||||||||||||||||
| 939 | *len = 0; | - | ||||||||||||||||||||||||
| 940 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 941 | } | - | ||||||||||||||||||||||||
| 942 | } executed 1007 times by 1 test: else {end of blockExecuted by:
| 1007 | ||||||||||||||||||||||||
| 943 | readbytes = 0; | - | ||||||||||||||||||||||||
| 944 | } executed 160 times by 1 test: end of blockExecuted by:
| 160 | ||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||
| 950 | if (readbytes != frag_len
| 0-1167 | ||||||||||||||||||||||||
| 951 | ossl_statem_fatal((s), (47), (370), (271), | - | ||||||||||||||||||||||||
| 952 | __FILE__ | - | ||||||||||||||||||||||||
| 953 | , | - | ||||||||||||||||||||||||
| 954 | 882 | - | ||||||||||||||||||||||||
| 955 | ) | - | ||||||||||||||||||||||||
| 956 | ; | - | ||||||||||||||||||||||||
| 957 | goto never executed: f_err;goto f_err;never executed: goto f_err; | 0 | ||||||||||||||||||||||||
| 958 | } | - | ||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||
| 962 | - | |||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||
| 966 | *len = s->init_num = frag_len; | - | ||||||||||||||||||||||||
| 967 | return executed 1167 times by 1 test: 1;return 1;Executed by:
executed 1167 times by 1 test: return 1;Executed by:
| 1167 | ||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||
| 969 | f_err: | - | ||||||||||||||||||||||||
| 970 | s->init_num = 0; | - | ||||||||||||||||||||||||
| 971 | *len = 0; | - | ||||||||||||||||||||||||
| 972 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 973 | } | - | ||||||||||||||||||||||||
| 974 | int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt) | - | ||||||||||||||||||||||||
| 975 | { | - | ||||||||||||||||||||||||
| 976 | if (s->version == 0x0100
| 1-358 | ||||||||||||||||||||||||
| 977 | s->d1->next_handshake_write_seq++; | - | ||||||||||||||||||||||||
| 978 | - | |||||||||||||||||||||||||
| 979 | if (!WPACKET_put_bytes__((pkt), (s->d1->handshake_write_seq), 2)
| 0-1 | ||||||||||||||||||||||||
| 980 | ossl_statem_fatal((s), (80), (371), ((4|64)), | - | ||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | __FILE__ | - | ||||||||||||||||||||||||
| 983 | , | - | ||||||||||||||||||||||||
| 984 | - | |||||||||||||||||||||||||
| 985 | 918 | - | ||||||||||||||||||||||||
| 986 | ) | - | ||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||
| 988 | ; | - | ||||||||||||||||||||||||
| 989 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 990 | } | - | ||||||||||||||||||||||||
| 991 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| 993 | return executed 359 times by 1 test: 1;return 1;Executed by:
executed 359 times by 1 test: return 1;Executed by:
| 359 | ||||||||||||||||||||||||
| 994 | } | - | ||||||||||||||||||||||||
| 995 | int dtls1_read_failed(SSL *s, int code) | - | ||||||||||||||||||||||||
| 996 | { | - | ||||||||||||||||||||||||
| 997 | if (code > 0
| 0-1204 | ||||||||||||||||||||||||
| 998 | ossl_statem_fatal((s), (80), (339), ((4|64)), | - | ||||||||||||||||||||||||
| 999 | __FILE__ | - | ||||||||||||||||||||||||
| 1000 | , | - | ||||||||||||||||||||||||
| 1001 | 972 | - | ||||||||||||||||||||||||
| 1002 | ) | - | ||||||||||||||||||||||||
| 1003 | ; | - | ||||||||||||||||||||||||
| 1004 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1005 | } | - | ||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | if (!dtls1_is_timer_expired(s)
| 0-1204 | ||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | - | |||||||||||||||||||||||||
| 1012 | return executed 1204 times by 1 test: code;return code;Executed by:
executed 1204 times by 1 test: return code;Executed by:
| 1204 | ||||||||||||||||||||||||
| 1013 | } | - | ||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||
| 1015 | if (!SSL_in_init(s)
| 0 | ||||||||||||||||||||||||
| 1016 | { | - | ||||||||||||||||||||||||
| 1017 | BIO_set_flags(SSL_get_rbio(s), 0x01); | - | ||||||||||||||||||||||||
| 1018 | return never executed: code;return code;never executed: return code; | 0 | ||||||||||||||||||||||||
| 1019 | } | - | ||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | return never executed: dtls1_handle_timeout(s);return dtls1_handle_timeout(s);never executed: return dtls1_handle_timeout(s); | 0 | ||||||||||||||||||||||||
| 1022 | } | - | ||||||||||||||||||||||||
| 1023 | - | |||||||||||||||||||||||||
| 1024 | int dtls1_get_queue_priority(unsigned short seq, int is_ccs) | - | ||||||||||||||||||||||||
| 1025 | { | - | ||||||||||||||||||||||||
| 1026 | return executed 3904 times by 1 test: seq * 2 - is_ccs;return seq * 2 - is_ccs;Executed by:
executed 3904 times by 1 test: return seq * 2 - is_ccs;Executed by:
| 3904 | ||||||||||||||||||||||||
| 1027 | } | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | int dtls1_retransmit_buffered_messages(SSL *s) | - | ||||||||||||||||||||||||
| 1030 | { | - | ||||||||||||||||||||||||
| 1031 | pqueue *sent = s->d1->sent_messages; | - | ||||||||||||||||||||||||
| 1032 | piterator iter; | - | ||||||||||||||||||||||||
| 1033 | pitem *item; | - | ||||||||||||||||||||||||
| 1034 | hm_fragment *frag; | - | ||||||||||||||||||||||||
| 1035 | int found = 0; | - | ||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | iter = pqueue_iterator(sent); | - | ||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||
| 1039 | for (item = pqueue_next(&iter); item !=
| 51-122 | ||||||||||||||||||||||||
| 1040 | ((void *)0)
| 51-122 | ||||||||||||||||||||||||
| 1041 | ; item = pqueue_next(&iter)) { | - | ||||||||||||||||||||||||
| 1042 | frag = (hm_fragment *)item->data; | - | ||||||||||||||||||||||||
| 1043 | if (dtls1_retransmit_message(s, (unsigned short)
| 0-122 | ||||||||||||||||||||||||
| 1044 | dtls1_get_queue_priority
| 0-122 | ||||||||||||||||||||||||
| 1045 | (frag->msg_header.seq,
| 0-122 | ||||||||||||||||||||||||
| 1046 | frag->msg_header.is_ccs), &found) <= 0
| 0-122 | ||||||||||||||||||||||||
| 1047 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1048 | } executed 122 times by 1 test: end of blockExecuted by:
| 122 | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | return executed 51 times by 1 test: 1;return 1;Executed by:
executed 51 times by 1 test: return 1;Executed by:
| 51 | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||
| 1053 | int dtls1_buffer_message(SSL *s, int is_ccs) | - | ||||||||||||||||||||||||
| 1054 | { | - | ||||||||||||||||||||||||
| 1055 | pitem *item; | - | ||||||||||||||||||||||||
| 1056 | hm_fragment *frag; | - | ||||||||||||||||||||||||
| 1057 | unsigned char seq64be[8]; | - | ||||||||||||||||||||||||
| 1058 | - | |||||||||||||||||||||||||
| 1059 | - | |||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | - | |||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | if (!((s->init_off == 0) != 0)
| 0-1891 | ||||||||||||||||||||||||
| 1064 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1065 | - | |||||||||||||||||||||||||
| 1066 | frag = dtls1_hm_fragment_new(s->init_num, 0); | - | ||||||||||||||||||||||||
| 1067 | if (frag ==
| 0-1891 | ||||||||||||||||||||||||
| 1068 | ((void *)0)
| 0-1891 | ||||||||||||||||||||||||
| 1069 | ) | - | ||||||||||||||||||||||||
| 1070 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | memcpy(frag->fragment, s->init_buf->data, s->init_num); | - | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | if (is_ccs
| 359-1532 | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | if (!((s->d1->w_msg_hdr.msg_len + ((
| 0-359 | ||||||||||||||||||||||||
| 1077 | - | |||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | ) | - | ||||||||||||||||||||||||
| 1080 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1081 | } executed 359 times by 1 test: else {end of blockExecuted by:
| 359 | ||||||||||||||||||||||||
| 1082 | if (!((s->d1->w_msg_hdr.msg_len + 12 == (unsigned int)s->init_num) != 0)
| 0-1532 | ||||||||||||||||||||||||
| 1083 | ) | - | ||||||||||||||||||||||||
| 1084 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1085 | } executed 1532 times by 1 test: end of blockExecuted by:
| 1532 | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; | - | ||||||||||||||||||||||||
| 1088 | frag->msg_header.seq = s->d1->w_msg_hdr.seq; | - | ||||||||||||||||||||||||
| 1089 | frag->msg_header.type = s->d1->w_msg_hdr.type; | - | ||||||||||||||||||||||||
| 1090 | frag->msg_header.frag_off = 0; | - | ||||||||||||||||||||||||
| 1091 | frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; | - | ||||||||||||||||||||||||
| 1092 | frag->msg_header.is_ccs = is_ccs; | - | ||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | frag->msg_header.saved_retransmit_state.enc_write_ctx = s->enc_write_ctx; | - | ||||||||||||||||||||||||
| 1096 | frag->msg_header.saved_retransmit_state.write_hash = s->write_hash; | - | ||||||||||||||||||||||||
| 1097 | frag->msg_header.saved_retransmit_state.compress = s->compress; | - | ||||||||||||||||||||||||
| 1098 | frag->msg_header.saved_retransmit_state.session = s->session; | - | ||||||||||||||||||||||||
| 1099 | frag->msg_header.saved_retransmit_state.epoch = | - | ||||||||||||||||||||||||
| 1100 | ((&s->rlayer)->d->w_epoch); | - | ||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | memset(seq64be, 0, sizeof(seq64be)); | - | ||||||||||||||||||||||||
| 1103 | seq64be[6] = | - | ||||||||||||||||||||||||
| 1104 | (unsigned | - | ||||||||||||||||||||||||
| 1105 | char)(dtls1_get_queue_priority(frag->msg_header.seq, | - | ||||||||||||||||||||||||
| 1106 | frag->msg_header.is_ccs) >> 8); | - | ||||||||||||||||||||||||
| 1107 | seq64be[7] = | - | ||||||||||||||||||||||||
| 1108 | (unsigned | - | ||||||||||||||||||||||||
| 1109 | char)(dtls1_get_queue_priority(frag->msg_header.seq, | - | ||||||||||||||||||||||||
| 1110 | frag->msg_header.is_ccs)); | - | ||||||||||||||||||||||||
| 1111 | - | |||||||||||||||||||||||||
| 1112 | item = pitem_new(seq64be, frag); | - | ||||||||||||||||||||||||
| 1113 | if (item ==
| 0-1891 | ||||||||||||||||||||||||
| 1114 | ((void *)0)
| 0-1891 | ||||||||||||||||||||||||
| 1115 | ) { | - | ||||||||||||||||||||||||
| 1116 | dtls1_hm_fragment_free(frag); | - | ||||||||||||||||||||||||
| 1117 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1118 | } | - | ||||||||||||||||||||||||
| 1119 | - | |||||||||||||||||||||||||
| 1120 | pqueue_insert(s->d1->sent_messages, item); | - | ||||||||||||||||||||||||
| 1121 | return executed 1891 times by 1 test: 1;return 1;Executed by:
executed 1891 times by 1 test: return 1;Executed by:
| 1891 | ||||||||||||||||||||||||
| 1122 | } | - | ||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||
| 1124 | int dtls1_retransmit_message(SSL *s, unsigned short seq, int *found) | - | ||||||||||||||||||||||||
| 1125 | { | - | ||||||||||||||||||||||||
| 1126 | int ret; | - | ||||||||||||||||||||||||
| 1127 | - | |||||||||||||||||||||||||
| 1128 | pitem *item; | - | ||||||||||||||||||||||||
| 1129 | hm_fragment *frag; | - | ||||||||||||||||||||||||
| 1130 | unsigned long header_length; | - | ||||||||||||||||||||||||
| 1131 | unsigned char seq64be[8]; | - | ||||||||||||||||||||||||
| 1132 | struct dtls1_retransmit_state saved_state; | - | ||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||
| 1135 | memset(seq64be, 0, sizeof(seq64be)); | - | ||||||||||||||||||||||||
| 1136 | seq64be[6] = (unsigned char)(seq >> 8); | - | ||||||||||||||||||||||||
| 1137 | seq64be[7] = (unsigned char)seq; | - | ||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||
| 1139 | item = pqueue_find(s->d1->sent_messages, seq64be); | - | ||||||||||||||||||||||||
| 1140 | if (item ==
| 0-122 | ||||||||||||||||||||||||
| 1141 | ((void *)0)
| 0-122 | ||||||||||||||||||||||||
| 1142 | ) { | - | ||||||||||||||||||||||||
| 1143 | ossl_statem_fatal((s), (80), (390), ((4|64)), | - | ||||||||||||||||||||||||
| 1144 | __FILE__ | - | ||||||||||||||||||||||||
| 1145 | , | - | ||||||||||||||||||||||||
| 1146 | 1115 | - | ||||||||||||||||||||||||
| 1147 | ) | - | ||||||||||||||||||||||||
| 1148 | ; | - | ||||||||||||||||||||||||
| 1149 | *found = 0; | - | ||||||||||||||||||||||||
| 1150 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1151 | } | - | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | *found = 1; | - | ||||||||||||||||||||||||
| 1154 | frag = (hm_fragment *)item->data; | - | ||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||
| 1156 | if (frag->msg_header.is_ccs
| 20-102 | ||||||||||||||||||||||||
| 1157 | header_length = 1; executed 20 times by 1 test: header_length = 1;Executed by:
| 20 | ||||||||||||||||||||||||
| 1158 | else | - | ||||||||||||||||||||||||
| 1159 | header_length = 12; executed 102 times by 1 test: header_length = 12;Executed by:
| 102 | ||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||
| 1161 | memcpy(s->init_buf->data, frag->fragment, | - | ||||||||||||||||||||||||
| 1162 | frag->msg_header.msg_len + header_length); | - | ||||||||||||||||||||||||
| 1163 | s->init_num = frag->msg_header.msg_len + header_length; | - | ||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||
| 1165 | dtls1_set_message_header_int(s, frag->msg_header.type, | - | ||||||||||||||||||||||||
| 1166 | frag->msg_header.msg_len, | - | ||||||||||||||||||||||||
| 1167 | frag->msg_header.seq, 0, | - | ||||||||||||||||||||||||
| 1168 | frag->msg_header.frag_len); | - | ||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | saved_state.enc_write_ctx = s->enc_write_ctx; | - | ||||||||||||||||||||||||
| 1172 | saved_state.write_hash = s->write_hash; | - | ||||||||||||||||||||||||
| 1173 | saved_state.compress = s->compress; | - | ||||||||||||||||||||||||
| 1174 | saved_state.session = s->session; | - | ||||||||||||||||||||||||
| 1175 | saved_state.epoch = ((&s->rlayer)->d->w_epoch); | - | ||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||
| 1177 | s->d1->retransmitting = 1; | - | ||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | s->enc_write_ctx = frag->msg_header.saved_retransmit_state.enc_write_ctx; | - | ||||||||||||||||||||||||
| 1181 | s->write_hash = frag->msg_header.saved_retransmit_state.write_hash; | - | ||||||||||||||||||||||||
| 1182 | s->compress = frag->msg_header.saved_retransmit_state.compress; | - | ||||||||||||||||||||||||
| 1183 | s->session = frag->msg_header.saved_retransmit_state.session; | - | ||||||||||||||||||||||||
| 1184 | DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer, | - | ||||||||||||||||||||||||
| 1185 | frag->msg_header. | - | ||||||||||||||||||||||||
| 1186 | saved_retransmit_state.epoch); | - | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | ret = dtls1_do_write(s, frag->msg_header.is_ccs ? | - | ||||||||||||||||||||||||
| 1189 | 20 : 22); | - | ||||||||||||||||||||||||
| 1190 | - | |||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | s->enc_write_ctx = saved_state.enc_write_ctx; | - | ||||||||||||||||||||||||
| 1193 | s->write_hash = saved_state.write_hash; | - | ||||||||||||||||||||||||
| 1194 | s->compress = saved_state.compress; | - | ||||||||||||||||||||||||
| 1195 | s->session = saved_state.session; | - | ||||||||||||||||||||||||
| 1196 | DTLS_RECORD_LAYER_set_saved_w_epoch(&s->rlayer, saved_state.epoch); | - | ||||||||||||||||||||||||
| 1197 | - | |||||||||||||||||||||||||
| 1198 | s->d1->retransmitting = 0; | - | ||||||||||||||||||||||||
| 1199 | - | |||||||||||||||||||||||||
| 1200 | (void)(int)BIO_ctrl(s->wbio,11,0, | - | ||||||||||||||||||||||||
| 1201 | ((void *)0) | - | ||||||||||||||||||||||||
| 1202 | ); | - | ||||||||||||||||||||||||
| 1203 | return executed 122 times by 1 test: ret;return ret;Executed by:
executed 122 times by 1 test: return ret;Executed by:
| 122 | ||||||||||||||||||||||||
| 1204 | } | - | ||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||
| 1206 | void dtls1_set_message_header(SSL *s, | - | ||||||||||||||||||||||||
| 1207 | unsigned char mt, size_t len, | - | ||||||||||||||||||||||||
| 1208 | size_t frag_off, size_t frag_len) | - | ||||||||||||||||||||||||
| 1209 | { | - | ||||||||||||||||||||||||
| 1210 | if (frag_off == 0
| 0-1532 | ||||||||||||||||||||||||
| 1211 | s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; | - | ||||||||||||||||||||||||
| 1212 | s->d1->next_handshake_write_seq++; | - | ||||||||||||||||||||||||
| 1213 | } executed 1532 times by 1 test: end of blockExecuted by:
| 1532 | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | dtls1_set_message_header_int(s, mt, len, s->d1->handshake_write_seq, | - | ||||||||||||||||||||||||
| 1216 | frag_off, frag_len); | - | ||||||||||||||||||||||||
| 1217 | } executed 1532 times by 1 test: end of blockExecuted by:
| 1532 | ||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||
| 1220 | static void | - | ||||||||||||||||||||||||
| 1221 | dtls1_set_message_header_int(SSL *s, unsigned char mt, | - | ||||||||||||||||||||||||
| 1222 | size_t len, unsigned short seq_num, | - | ||||||||||||||||||||||||
| 1223 | size_t frag_off, size_t frag_len) | - | ||||||||||||||||||||||||
| 1224 | { | - | ||||||||||||||||||||||||
| 1225 | struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; | - | ||||||||||||||||||||||||
| 1226 | - | |||||||||||||||||||||||||
| 1227 | msg_hdr->type = mt; | - | ||||||||||||||||||||||||
| 1228 | msg_hdr->msg_len = len; | - | ||||||||||||||||||||||||
| 1229 | msg_hdr->seq = seq_num; | - | ||||||||||||||||||||||||
| 1230 | msg_hdr->frag_off = frag_off; | - | ||||||||||||||||||||||||
| 1231 | msg_hdr->frag_len = frag_len; | - | ||||||||||||||||||||||||
| 1232 | } executed 2013 times by 1 test: end of blockExecuted by:
| 2013 | ||||||||||||||||||||||||
| 1233 | - | |||||||||||||||||||||||||
| 1234 | static void | - | ||||||||||||||||||||||||
| 1235 | dtls1_fix_message_header(SSL *s, size_t frag_off, size_t frag_len) | - | ||||||||||||||||||||||||
| 1236 | { | - | ||||||||||||||||||||||||
| 1237 | struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; | - | ||||||||||||||||||||||||
| 1238 | - | |||||||||||||||||||||||||
| 1239 | msg_hdr->frag_off = frag_off; | - | ||||||||||||||||||||||||
| 1240 | msg_hdr->frag_len = frag_len; | - | ||||||||||||||||||||||||
| 1241 | } executed 3668 times by 1 test: end of blockExecuted by:
| 3668 | ||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p) | - | ||||||||||||||||||||||||
| 1244 | { | - | ||||||||||||||||||||||||
| 1245 | struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; | - | ||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | *p++ = msg_hdr->type; | - | ||||||||||||||||||||||||
| 1248 | (((p)[0]=(unsigned char)(((msg_hdr->msg_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_hdr->msg_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_hdr->msg_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 1249 | - | |||||||||||||||||||||||||
| 1250 | (((p)[0]=(unsigned char)(((msg_hdr->seq)>> 8)&0xff), (p)[1]=(unsigned char)(((msg_hdr->seq) )&0xff)),(p)+=2); | - | ||||||||||||||||||||||||
| 1251 | (((p)[0]=(unsigned char)(((msg_hdr->frag_off)>>16)&0xff), (p)[1]=(unsigned char)(((msg_hdr->frag_off)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_hdr->frag_off) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 1252 | (((p)[0]=(unsigned char)(((msg_hdr->frag_len)>>16)&0xff), (p)[1]=(unsigned char)(((msg_hdr->frag_len)>> 8)&0xff), (p)[2]=(unsigned char)(((msg_hdr->frag_len) )&0xff)),(p)+=3); | - | ||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||
| 1254 | return executed 2651 times by 1 test: p;return p;Executed by:
executed 2651 times by 1 test: return p;Executed by:
| 2651 | ||||||||||||||||||||||||
| 1255 | } | - | ||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||
| 1257 | void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) | - | ||||||||||||||||||||||||
| 1258 | { | - | ||||||||||||||||||||||||
| 1259 | memset(msg_hdr, 0, sizeof(*msg_hdr)); | - | ||||||||||||||||||||||||
| 1260 | msg_hdr->type = *(data++); | - | ||||||||||||||||||||||||
| 1261 | ((msg_hdr->msg_len =(((unsigned long)((data)[0]))<<16)| (((unsigned long)((data)[1]))<< 8)| (((unsigned long)((data)[2])) )),(data)+=3); | - | ||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||
| 1263 | ((msg_hdr->seq=(((unsigned int)((data)[0]))<< 8)| (((unsigned int)((data)[1])) )),(data)+=2); | - | ||||||||||||||||||||||||
| 1264 | ((msg_hdr->frag_off =(((unsigned long)((data)[0]))<<16)| (((unsigned long)((data)[1]))<< 8)| (((unsigned long)((data)[2])) )),(data)+=3); | - | ||||||||||||||||||||||||
| 1265 | ((msg_hdr->frag_len =(((unsigned long)((data)[0]))<<16)| (((unsigned long)((data)[1]))<< 8)| (((unsigned long)((data)[2])) )),(data)+=3); | - | ||||||||||||||||||||||||
| 1266 | } executed 2579 times by 1 test: end of blockExecuted by:
| 2579 | ||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||
| 1268 | int dtls1_set_handshake_header(SSL *s, WPACKET *pkt, int htype) | - | ||||||||||||||||||||||||
| 1269 | { | - | ||||||||||||||||||||||||
| 1270 | unsigned char *header; | - | ||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||
| 1272 | if (htype == 0x0101
| 359-1532 | ||||||||||||||||||||||||
| 1273 | s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; | - | ||||||||||||||||||||||||
| 1274 | dtls1_set_message_header_int(s, 1, 0, | - | ||||||||||||||||||||||||
| 1275 | s->d1->handshake_write_seq, 0, 0); | - | ||||||||||||||||||||||||
| 1276 | if (!WPACKET_put_bytes__((pkt), (1), 1)
| 0-359 | ||||||||||||||||||||||||
| 1277 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1278 | } executed 359 times by 1 test: else {end of blockExecuted by:
| 359 | ||||||||||||||||||||||||
| 1279 | dtls1_set_message_header(s, htype, 0, 0, 0); | - | ||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | if (!WPACKET_allocate_bytes(pkt, 12, &header)
| 0-1532 | ||||||||||||||||||||||||
| 1285 | || !WPACKET_start_sub_packet(pkt)
| 0-1532 | ||||||||||||||||||||||||
| 1286 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1287 | } executed 1532 times by 1 test: end of blockExecuted by:
| 1532 | ||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | return executed 1891 times by 1 test: 1;return 1;Executed by:
executed 1891 times by 1 test: return 1;Executed by:
| 1891 | ||||||||||||||||||||||||
| 1290 | } | - | ||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | int dtls1_close_construct_packet(SSL *s, WPACKET *pkt, int htype) | - | ||||||||||||||||||||||||
| 1293 | { | - | ||||||||||||||||||||||||
| 1294 | size_t msglen; | - | ||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||
| 1296 | if ((htype != 0x0101
| 0-1532 | ||||||||||||||||||||||||
| 1297 | || !WPACKET_get_length(pkt, &msglen)
| 0-1891 | ||||||||||||||||||||||||
| 1298 | || msglen > 0x7fffffff
| 0-1891 | ||||||||||||||||||||||||
| 1299 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||
| 1301 | if (htype != 0x0101
| 359-1532 | ||||||||||||||||||||||||
| 1302 | s->d1->w_msg_hdr.msg_len = msglen - 12; | - | ||||||||||||||||||||||||
| 1303 | s->d1->w_msg_hdr.frag_len = msglen - 12; | - | ||||||||||||||||||||||||
| 1304 | } executed 1532 times by 1 test: end of blockExecuted by:
| 1532 | ||||||||||||||||||||||||
| 1305 | s->init_num = (int)msglen; | - | ||||||||||||||||||||||||
| 1306 | s->init_off = 0; | - | ||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | if (htype != 3
| 0-1891 | ||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | if (!dtls1_buffer_message(s, htype == 0x0101
| 0-1891 | ||||||||||||||||||||||||
| 1311 | ? 1 : 0)
| 0-1891 | ||||||||||||||||||||||||
| 1312 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1313 | } executed 1891 times by 1 test: end of blockExecuted by:
| 1891 | ||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||
| 1315 | return executed 1891 times by 1 test: 1;return 1;Executed by:
executed 1891 times by 1 test: return 1;Executed by:
| 1891 | ||||||||||||||||||||||||
| 1316 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |