avformat/http: properly fall back on soft seek failure

If the HTTP server still has stale bytes in the TCP receive buffer, but
the underlying conection was already closed, then the http_open_cnx()
call might fail even though we successfully drained the previous request.

In this case, there is no proper fallback to a new connection, leading to
sudden truncation.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-06-14 13:03:34 +02:00
parent 0d0f9a06ab
commit f87323a359

View File

@@ -2163,6 +2163,15 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
}
remaining -= ret;
}
ret = http_open_cnx(h, &options);
if (ret >= 0) {
goto done;
} else {
/* fall back to normal reconnection */
ffurl_closep(&s->hd);
old_hd = NULL;
}
} else {
/* can't soft seek; always open new connection */
old_hd = s->hd;
@@ -2181,6 +2190,8 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
av_dict_free(&options);
return ret;
}
done:
av_dict_free(&options);
ffurl_close(old_hd);
return off;