diff options
author | David Timber <mieabby@gmail.com> | 2020-09-08 19:46:44 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-09-08 20:10:57 +0930 |
commit | 0e512e6ae3146fcf3ce2427c8c36937d708d149b (patch) | |
tree | 40a6ad8c64b419e2f8d0bcc289e9608852ff76ae /src/htbt.c | |
parent | 550d2eec27a42254b26139208765022fffe7c775 (diff) |
* Fix bug in pth_poll: wrong use of FD_SET()
causing undefined behaviour
* Fix bug in proone: loading ns pool from dvault for resolv
* Fix bug in htbt: improper handling of stream in htbt_relay_child()
* Switch back to _POSIX_C_SOURCE=200112L
Diffstat (limited to 'src/htbt.c')
-rw-r--r-- | src/htbt.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -352,7 +352,7 @@ static prne_htbt_status_code_t htbt_relay_child ( * Await cv if you want to terminate the connection right away * when the program is terminating. */ - f_ret = pth_poll_ev(pfd, 5, -1, ev); + f_ret = prne_pth_poll(pfd, 5, -1, ev); if (f_ret < 0 && errno != EINTR) { ret = PRNE_HTBT_STATUS_ERRNO; break; @@ -392,6 +392,13 @@ static prne_htbt_status_code_t htbt_relay_child ( consume += actual; prne_iobuf_shift(ctx->iobuf + 0, -consume); } while (false); + + if (sh[0].len == 0 && pfd[0].fd < 0) { + // There's still pending stdin data and EOF. + // This is proto err. + ret = PRNE_HTBT_STATUS_PROTO_ERR; + break; + } } if (pfd[0].revents) { @@ -401,12 +408,6 @@ static prne_htbt_status_code_t htbt_relay_child ( ctx->iobuf[0].avail); if (f_ret == 0) { pfd[0].fd = -1; - if (sh[0].len > 0) { - // There's still pending stdin data and EOF. - // This is proto err. - ret = PRNE_HTBT_STATUS_PROTO_ERR; - break; - } } else if (f_ret < 0) { ctx->valid = false; @@ -765,7 +766,7 @@ static void htbt_slv_consume_outbuf ( pfd.events = POLLOUT; while (ctx->valid && ctx->iobuf[1].len > 0) { - fret = pth_poll_ev(&pfd, 1, -1, root_ev); + fret = prne_pth_poll(&pfd, 1, -1, root_ev); if (root_ev != NULL && pth_event_status(root_ev) != PTH_STATUS_PENDING) { @@ -1098,7 +1099,7 @@ static bool htbt_slv_srv_bin ( prne_assert(ev != NULL); if (ctx->iobuf[0].len == 0) { - f_ret = pth_poll_ev(&pfd, 1, -1, ev); + f_ret = prne_pth_poll(&pfd, 1, -1, ev); if (pth_event_status(ev) == PTH_STATUS_OCCURRED || f_ret == 0) { |