Skip to content

Commit 99e1f3a

Browse files
committed
Treat write_cb() == 0 as an error
Otherwise, we'll end up infinite looping when trying to write a record. ffmpeg will return 0 if the connection is interrupted via the AVIO interrupt callback, triggering this behavior.
1 parent 02e8472 commit 99e1f3a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tls.c

+15
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,19 @@ tls_reset(struct tls *ctx)
596596
ctx->cb_arg = NULL;
597597
}
598598

599+
/*
600+
* Run the TLS engine until the target state is reached, or an error
601+
* occurs.
602+
*
603+
* Return value:
604+
* 1 The desired state was reached.
605+
* 0 The engine was closed without error, or the read callback
606+
* returned 0 and the handshake was completed.
607+
* -1 The engine encountered an error, or the read or write
608+
* callback returned -1, or the write callback returned 0.
609+
* <0 The read or write callback returned some other negative
610+
* value (for instance, TLS_WANT_POLLIN or TLS_WANT_POLLOUT).
611+
*/
599612
static int
600613
tls_run_until(struct tls *ctx, unsigned target, const char *prefix)
601614
{
@@ -618,6 +631,8 @@ tls_run_until(struct tls *ctx, unsigned target, const char *prefix)
618631
if (state & BR_SSL_SENDREC) {
619632
buf = br_ssl_engine_sendrec_buf(eng, &len);
620633
ret = (ctx->write_cb)(ctx, buf, len, ctx->cb_arg);
634+
if (ret == 0)
635+
ret = -1;
621636
if (ret == -1)
622637
tls_set_error(ctx, "%s failed", prefix);
623638
if (ret < 0) {

0 commit comments

Comments
 (0)