| line |
true |
false |
branch |
|
34
|
51 |
51 |
for (i = 0; i < num_protos; i++) { |
|
35
|
0 |
51 |
for (j = 0; j < params->negotiated_protocols.count; j++) { |
|
36
|
0 |
0 |
if (params->negotiated_protocols.list[j].len == protos[i].len && |
|
38
|
0 |
0 |
protos[i].len) == 0) { |
|
108
|
3 |
84 |
if (ret != 0) { |
|
117
|
2 |
82 |
if (!fp) { |
|
125
|
0 |
82 |
if (!pkey) { |
|
132
|
0 |
82 |
if (ptls_openssl_init_sign_certificate(sign_cert, pkey) != 0) { |
|
142
|
0 |
82 |
if (h2) |
|
161
|
0 |
86 |
if (!ctx) return; |
|
162
|
86 |
0 |
if (ctx->certificates.list) { |
|
164
|
83 |
86 |
for (i = 0; i < ctx->certificates.count; i++) |
|
169
|
81 |
5 |
if (ctx->sign_certificate) { |
|
203
|
81 |
64 |
if (--ref->refcount <= 0) { |
|
216
|
0 |
68 |
if (unlikely(!c->tls)) { |
|
233
|
63 |
562 |
if (c->tls) { |
|
237
|
63 |
562 |
if (c->tls_ctx_ref) { |
|
242
|
0 |
625 |
if (c->tls_rbuf) { |
|
247
|
9 |
616 |
if (c->tls_tunnel) { |
|
251
|
9 |
0 |
if (c->tls_tunnel_sv0 >= 0) { |
|
255
|
0 |
9 |
if (c->tls_tunnel_sv1 >= 0) { |
|
259
|
0 |
9 |
if (c->tls_tunnel_wbuf) { |
|
275
|
0 |
140 |
if (c->tls_wbuf.off == 0) |
|
279
|
0 |
140 |
if (written < 0) { |
|
280
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { |
|
287
|
0 |
140 |
if ((size_t)written < c->tls_wbuf.off) { |
|
323
|
0 |
13 |
if (c->tls_tunnel_sv0 < 0) return -1; |
|
326
|
13 |
0 |
if (nw == (ssize_t)len) |
|
329
|
0 |
0 |
if (nw < 0) { |
|
330
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
|
0 |
0 |
if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) |
|
336
|
0 |
0 |
if (!c->tls_tunnel_wbuf) { |
|
341
|
0 |
0 |
if (c->tls_tunnel_wbuf_pos > 0) { |
|
343
|
0 |
0 |
if (remain > 0) |
|
351
|
0 |
0 |
if (SvCUR(c->tls_tunnel_wbuf) + remaining > FEER_TUNNEL_MAX_WBUF) { |
|
357
|
0 |
0 |
if (!ev_is_active(&c->tls_tunnel_write_w)) |
|
371
|
13 |
0 |
while (c->tls_tunnel && c->tls_rbuf_len > 0) { |
|
|
0 |
13 |
while (c->tls_tunnel && c->tls_rbuf_len > 0) { |
|
372
|
0 |
0 |
if (ev_is_active(&c->tls_tunnel_write_w)) |
|
376
|
0 |
0 |
if (drain_rv < 0) break; |
|
377
|
0 |
0 |
if (drain_rv == 1) continue; /* non-data (e.g. KeyUpdate) */ |
|
378
|
0 |
0 |
if (tls_tunnel_write_or_buffer(c, (const char *)db.base, db.off) < 0) { |
|
399
|
2 |
21 |
if (nread == 0) { |
|
405
|
0 |
21 |
if (nread < 0) { |
|
406
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
414
|
0 |
21 |
if (feer_tls_send(c, buf, nread) != 0) { |
|
422
|
0 |
21 |
if (flush_ret == -2) { |
|
427
|
21 |
0 |
if (c->tls_wbuf.off > 0) |
|
445
|
0 |
0 |
if (!c->tls_tunnel_wbuf || |
|
446
|
0 |
0 |
SvCUR(c->tls_tunnel_wbuf) <= c->tls_tunnel_wbuf_pos) { |
|
448
|
0 |
0 |
if (c->tls_tunnel_wbuf) { |
|
459
|
0 |
0 |
if (nw < 0) { |
|
460
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
468
|
0 |
0 |
if (c->tls_tunnel_wbuf_pos >= SvCUR(c->tls_tunnel_wbuf)) { |
|
474
|
0 |
0 |
if (c->tls_rbuf_len > 0) |
|
488
|
0 |
9 |
if (c->tls_tunnel) return; |
|
491
|
0 |
9 |
if (feer_socketpair_nb(sv) < 0) { |
|
512
|
9 |
0 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
|
9 |
0 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
|
0 |
9 |
if (c->rbuf && SvOK(c->rbuf) && SvCUR(c->rbuf) > 0) { |
|
514
|
0 |
0 |
if (tls_tunnel_write_or_buffer(c, SvPVX(c->rbuf), SvCUR(c->rbuf)) < 0) { |
|
537
|
0 |
60 |
if (!c->tls_rbuf || c->tls_rbuf_len == 0) return -1; |
|
|
0 |
0 |
if (!c->tls_rbuf || c->tls_rbuf_len == 0) return -1; |
|
547
|
0 |
0 |
if (ret == 0 && consumed < saved_len) { |
|
|
0 |
0 |
if (ret == 0 && consumed < saved_len) { |
|
555
|
0 |
0 |
if (ret != 0) { |
|
559
|
0 |
0 |
if (decbuf->off == 0) { |
|
608
|
1 |
347 |
if (unlikely(c->pipelined)) goto tls_pipelined; |
|
610
|
0 |
347 |
if (unlikely(!c->tls)) { |
|
621
|
7 |
340 |
if (nread == 0) { |
|
630
|
0 |
340 |
if (nread < 0) { |
|
631
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
644
|
152 |
188 |
if (unlikely(c->receiving == RECEIVE_PROXY_HEADER)) { |
|
645
|
23 |
129 |
if (!c->rbuf) { |
|
651
|
4 |
148 |
if (ret == -1) { |
|
656
|
129 |
19 |
if (ret == -2) goto tls_read_cleanup; /* need more data */ |
|
662
|
0 |
19 |
feer_clear_remote_cache(c); |
|
|
0 |
19 |
feer_clear_remote_cache(c); |
|
666
|
0 |
19 |
if (remaining > 0) { |
|
677
|
19 |
0 |
if (remaining == 0) |
|
690
|
0 |
188 |
if (c->tls_rbuf_len > 0) { |
|
691
|
0 |
0 |
if (nread > 0) { |
|
708
|
64 |
124 |
if (!c->tls_handshake_done) { |
|
716
|
55 |
9 |
if (hsbuf.off > 0) { |
|
717
|
0 |
55 |
if (tls_wbuf_append(&c->tls_wbuf, hsbuf.base, hsbuf.off) != 0) { |
|
720
|
0 |
0 |
if (merged) Safefree(merged); |
|
725
|
0 |
55 |
if (flush_ret == -2) { |
|
728
|
0 |
0 |
if (merged) Safefree(merged); |
|
732
|
55 |
0 |
if (flush_ret == -1 || c->tls_wbuf.off > 0) { |
|
|
0 |
55 |
if (flush_ret == -1 || c->tls_wbuf.off > 0) { |
|
739
|
51 |
13 |
if (ret == 0) { |
|
746
|
0 |
51 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
|
0 |
0 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
|
0 |
0 |
if (proto && strlen(proto) == 2 && memcmp(proto, "h2", 2) == 0) { |
|
757
|
0 |
51 |
if (consumed < inlen) { |
|
805
|
0 |
0 |
if (dec_ret != 0) { |
|
807
|
0 |
0 |
if (merged) Safefree(merged); |
|
812
|
0 |
0 |
if (dec_consumed < remaining) { |
|
818
|
0 |
0 |
if (decbuf.off > 0) { |
|
820
|
0 |
0 |
if (!c->rbuf) { |
|
828
|
0 |
0 |
if (parse_ret == -1) { |
|
831
|
0 |
0 |
if (merged) Safefree(merged); |
|
834
|
0 |
0 |
if (parse_ret > 0) { |
|
835
|
0 |
0 |
if (!process_request_headers(c, parse_ret)) |
|
842
|
0 |
0 |
if (c->tls_rbuf_len > 0) { |
|
844
|
0 |
0 |
while (c->tls_rbuf_len > 0) { |
|
846
|
0 |
0 |
if (drain_rv < 0) break; |
|
847
|
0 |
0 |
if (drain_rv == 1) continue; |
|
851
|
0 |
0 |
if (parse_ret == -2) { |
|
855
|
0 |
0 |
if (pr == -1) { |
|
860
|
0 |
0 |
if (pr > 0) { |
|
861
|
0 |
0 |
if (!process_request_headers(c, pr)) |
|
870
|
0 |
0 |
if (parse_ret > 0 && c->receiving == RECEIVE_BODY) { |
|
|
0 |
0 |
if (parse_ret > 0 && c->receiving == RECEIVE_BODY) { |
|
872
|
0 |
0 |
if (c->expected_cl > 0 |
|
873
|
0 |
0 |
&& c->received_cl >= c->expected_cl) { |
|
883
|
9 |
4 |
} else if (ret == PTLS_ERROR_IN_PROGRESS) { |
|
887
|
0 |
9 |
if (consumed < inlen) { |
|
899
|
0 |
64 |
if (merged) Safefree(merged); |
|
911
|
124 |
0 |
if (ret == 0 && consumed < inlen) { |
|
|
0 |
124 |
if (ret == 0 && consumed < inlen) { |
|
918
|
0 |
124 |
if (merged) Safefree(merged); |
|
920
|
0 |
124 |
if (ret != 0) { |
|
932
|
51 |
73 |
if (decbuf.off == 0) { |
|
955
|
13 |
60 |
if (c->tls_tunnel) { |
|
956
|
0 |
13 |
if (tls_tunnel_write_or_buffer(c, (const char *)decbuf.base, decbuf.off) < 0) { |
|
976
|
51 |
9 |
if (!c->rbuf) { |
|
986
|
0 |
60 |
while ((drain_rv = feer_tls_drain_one_record(c, &db)) >= 0) { |
|
987
|
0 |
0 |
if (drain_rv == 1) continue; /* non-data TLS record */ |
|
1002
|
8 |
53 |
if (c->receiving == RECEIVE_WAIT) |
|
1005
|
59 |
2 |
if (likely(c->receiving <= RECEIVE_HEADERS)) { |
|
1007
|
0 |
59 |
if (parse_ret == -1) { |
|
1012
|
0 |
59 |
if (parse_ret == -2) { |
|
1017
|
57 |
2 |
if (!process_request_headers(c, parse_ret)) |
|
1020
|
2 |
0 |
else if (likely(c->receiving == RECEIVE_BODY)) { |
|
1022
|
2 |
0 |
if (c->received_cl >= c->expected_cl) { |
|
1027
|
0 |
0 |
else if (c->receiving == RECEIVE_CHUNKED) { |
|
1029
|
0 |
0 |
if (ret == -1) { |
|
1033
|
0 |
0 |
else if (ret == 0) { |
|
1039
|
0 |
0 |
else if (c->receiving == RECEIVE_STREAMING) { |
|
1041
|
0 |
0 |
if (c->poll_read_cb) { |
|
1044
|
0 |
0 |
if (c->receiving >= RECEIVE_SHUTDOWN) { |
|
1048
|
0 |
0 |
if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) |
|
|
0 |
0 |
if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) |
|
1073
|
0 |
60 |
if (unlikely(!c->tls)) { |
|
1080
|
0 |
60 |
if (c->tls_wbuf.off > 0) { |
|
1082
|
0 |
0 |
if (flush_ret == -1) goto tls_write_cleanup; /* EAGAIN, keep write watcher active */ |
|
1083
|
0 |
0 |
if (flush_ret == -2) goto tls_write_error; |
|
1085
|
0 |
0 |
if (c->tls_wbuf.off > 0) goto tls_write_cleanup; |
|
1110
|
60 |
0 |
if (c->wbuf_rinq && c->cached_wbuf_low_water > 0 |
|
|
1 |
59 |
if (c->wbuf_rinq && c->cached_wbuf_low_water > 0 |
|
1111
|
1 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1112
|
1 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
1 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1113
|
0 |
1 |
if (c->poll_write_cb_is_io_handle) |
|
1120
|
60 |
0 |
if (c->wbuf_rinq) { |
|
1122
|
63 |
60 |
while ((m = (struct iomatrix *)rinq_shift(&c->wbuf_rinq)) != NULL) { |
|
1124
|
65 |
63 |
for (i = 0; i < m->count; i++) { |
|
1125
|
0 |
65 |
if (m->iov[i].iov_len == 0) continue; |
|
1133
|
0 |
65 |
if (ret != 0) { |
|
1137
|
0 |
0 |
for (j = 0; j < m->count; j++) { |
|
1138
|
0 |
0 |
if (m->sv[j]) SvREFCNT_dec(m->sv[j]); |
|
1140
|
0 |
0 |
IOMATRIX_FREE(m); |
|
1143
|
65 |
0 |
if (encbuf.off > 0) { |
|
1144
|
0 |
65 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |
|
1148
|
0 |
0 |
for (j = 0; j < m->count; j++) { |
|
1149
|
0 |
0 |
if (m->sv[j]) SvREFCNT_dec(m->sv[j]); |
|
1151
|
0 |
0 |
IOMATRIX_FREE(m); |
|
1159
|
65 |
63 |
for (i = 0; i < m->count; i++) { |
|
1160
|
65 |
0 |
if (m->sv[i]) SvREFCNT_dec(m->sv[i]); |
|
1162
|
63 |
0 |
IOMATRIX_FREE(m); |
|
1165
|
4 |
59 |
if (c->cached_wbuf_low_water > 0 |
|
1166
|
4 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water |
|
1167
|
3 |
1 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
3 |
0 |
&& c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1168
|
0 |
3 |
if (c->poll_write_cb_is_io_handle) |
|
1178
|
0 |
60 |
if (flush_ret == -1) goto tls_write_cleanup; /* EAGAIN */ |
|
1179
|
0 |
60 |
if (flush_ret == -2) goto tls_write_error; |
|
1180
|
60 |
0 |
if (flush_ret > 0) restart_write_timer(c); |
|
1184
|
2 |
58 |
if (c->sendfile_fd >= 0 && c->sendfile_remain > 0) { |
|
|
0 |
2 |
if (c->sendfile_fd >= 0 && c->sendfile_remain > 0) { |
|
1187
|
0 |
2 |
if (to_read > sizeof(filebuf)) to_read = sizeof(filebuf); |
|
1190
|
0 |
2 |
if (file_nread < 0) { |
|
1191
|
0 |
0 |
if (errno == EINTR) |
|
1194
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1198
|
0 |
2 |
if (file_nread == 0) { |
|
1199
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1208
|
0 |
2 |
if (ret != 0) { |
|
1211
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1216
|
2 |
0 |
if (encbuf.off > 0) { |
|
1217
|
0 |
2 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |
|
1220
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
0 |
CLOSE_SENDFILE_FD(c); |
|
1229
|
2 |
0 |
if (c->sendfile_remain == 0) { |
|
1230
|
2 |
0 |
CLOSE_SENDFILE_FD(c); |
|
|
0 |
2 |
CLOSE_SENDFILE_FD(c); |
|
1237
|
0 |
2 |
if (sf_flush_ret == -1) goto tls_write_cleanup; /* EAGAIN */ |
|
1238
|
0 |
2 |
if (sf_flush_ret == -2) goto tls_write_error; |
|
1240
|
2 |
0 |
if (c->sendfile_remain > 0 || c->tls_wbuf.off > 0) |
|
|
0 |
2 |
if (c->sendfile_remain > 0 || c->tls_wbuf.off > 0) |
|
1246
|
0 |
60 |
if ((!c->wbuf_rinq || (c->cached_wbuf_low_water > 0 |
|
|
0 |
0 |
if ((!c->wbuf_rinq || (c->cached_wbuf_low_water > 0 |
|
1247
|
0 |
0 |
&& c->wbuf_len <= c->cached_wbuf_low_water)) |
|
1248
|
60 |
0 |
&& c->sendfile_fd < 0 && c->tls_wbuf.off == 0) { |
|
|
60 |
0 |
&& c->sendfile_fd < 0 && c->tls_wbuf.off == 0) { |
|
1249
|
10 |
50 |
if (c->responding == RESPOND_SHUTDOWN || c->responding == RESPOND_NORMAL) { |
|
|
0 |
10 |
if (c->responding == RESPOND_SHUTDOWN || c->responding == RESPOND_NORMAL) { |
|
1251
|
10 |
0 |
} else if (c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
|
10 |
0 |
} else if (c->responding == RESPOND_STREAMING && c->poll_write_cb) { |
|
1252
|
0 |
10 |
if (c->poll_write_cb_is_io_handle) |
|
1256
|
0 |
0 |
} else if (c->responding == RESPOND_STREAMING) { |
|
1259
|
0 |
0 |
} else if (c->responding == RESPOND_NOT_STARTED) { |
|
1284
|
23 |
0 |
if (!c->tls || len == 0) return 0; |
|
|
0 |
23 |
if (!c->tls || len == 0) return 0; |
|
1289
|
0 |
23 |
if (ret != 0) { |
|
1294
|
23 |
0 |
if (encbuf.off > 0) { |
|
1295
|
0 |
23 |
if (tls_wbuf_append(&c->tls_wbuf, encbuf.base, encbuf.off) != 0) { |