Skip to content

Commit

Permalink
Ensure only 1 ICY packet processed per reading (earlephilhower#356)
Browse files Browse the repository at this point in the history
Thanks to @cjwhoishe, fixes earlephilhower#355 .

When a large enough read size was requested it is possible that for some
streams multiple ICY blocks could appear.  The logic doesn't support
that, so only read up to 1/2 the ICY block interval to ensure there is
no way to see two ICY blocks in one readInternal call.
  • Loading branch information
earlephilhower authored Dec 29, 2020
1 parent 435e2cf commit 7cb02a6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AudioFileSourceICYStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ AudioFileSourceICYStream::~AudioFileSourceICYStream()

uint32_t AudioFileSourceICYStream::readInternal(void *data, uint32_t len, bool nonBlock)
{
// Ensure we can't possibly read 2 ICY headers in a single go #355
len = std::min((int)(icyMetaInt >> 1), (int)len);
retry:
if (!http.connected()) {
cb.st(STATUS_DISCONNECTED, PSTR("Stream disconnected"));
Expand Down

0 comments on commit 7cb02a6

Please sign in to comment.