A bad connection causes an inifinite loop (at least on an ESP32 but I think also on an Arduino) #68
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
The problem of #56 is even bigger:
::ClientRead()
and::ClientWrite()
are called in bearssl ssl_io.c. If the socket client connection (Client *c
) is lost or reset by the peer, bothc->read(buf, len)
andc->write(buf, len)
will return a 0 (at least on the ESP32 but I think this is standard behavior also on an Arduino) thus causing an infinite loop instatic int run_until(br_sslio_context *ctx, unsigned target)
in ssl_io.c.In my situation this problem occurs on a bad WiFi connection, but I think it may also occur on a bad tcp/ip connection or if the peer closes the connection.
One solution would be to add a timeout in the
run_until()
function, but I think it is better not to touch the original library. So I made adaptations to::ClientRead()
and::ClientWrite()
that involve static variables, which I think is a bad programming habit, but this is the only way to record a state between calls to these functions.I did not introduce a new timeout value, but use the value of the socket client
c->getTimeout()
.The text was updated successfully, but these errors were encountered: