diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-13 11:36:16 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2021-01-13 11:36:16 +0000 |
commit | cc7dccb1858e73176814c3a8457ff6f94ff45662 (patch) | |
tree | 746a462d3a58b4dc19c240bcbf9f224e593e23e7 /src/sbearssl | |
parent | 23f7b20aeac1d337587d4f59779df94c82dc06b7 (diff) | |
download | s6-networking-cc7dccb1858e73176814c3a8457ff6f94ff45662.tar.xz |
Implement handshake timeout for libtls backend
Diffstat (limited to 'src/sbearssl')
-rw-r--r-- | src/sbearssl/sbearssl_run.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sbearssl/sbearssl_run.c b/src/sbearssl/sbearssl_run.c index e097698..fda9f3e 100644 --- a/src/sbearssl/sbearssl_run.c +++ b/src/sbearssl/sbearssl_run.c @@ -29,7 +29,7 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint for (;;) { - tain_t deadline = tain_infinite_relative ; + tain_t deadline = TAIN_INFINITE ; unsigned int j = 0 ; unsigned int state = br_ssl_engine_current_state(ctx) ; int r ; @@ -79,13 +79,16 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint if (xindex[0] == 4 && xindex[1] == 4 && xindex[3] == 4) { if (!j || handshake_done) break ; - deadline = *tto ; + tain_add_g(&deadline, tto) ; } - tain_add_g(&deadline, &deadline) ; r = iopause_g(x, j, &deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; - else if (!r) break ; + else if (!r) + { + if (verbosity) strerr_dief1x(98, "handshake timed out") ; + else _exit(98) ; + } while (j--) if (x[j].revents & IOPAUSE_EXCEPT) |