diff --git a/AudioFile.h b/AudioFile.h index 4e33651..aa33f50 100644 --- a/AudioFile.h +++ b/AudioFile.h @@ -1317,7 +1317,13 @@ int AudioFile::getIndexOfChunk (const std::vector& source, const std if ((i + 4) >= source.size()) return -1; - auto chunkSize = fourBytesToInt (source, i, endianness); + int32_t chunkSize = fourBytesToInt (source, i, endianness); + // Assume chunk size is invalid if it's greater than the number of bytes remaining in source + if (chunkSize > (source.size() - i - dataLen) || (chunkSize < 0)) + { + assert (false && "Invalid chunk size"); + return -1; + } i += (dataLen + chunkSize); } diff --git a/README.md b/README.md index 4886e94..4c08937 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ Many thanks to the following people for their contributions to this library: * [emiro85](https://github.com/emiro85) * [heartofrain](https://github.com/heartofrain) * [helloimmatt](https://github.com/helloimmatt/) +* [leocstone](https://github.com/leocstone) * [MatthieuHernandez](https://github.com/MatthieuHernandez) * [mrpossoms](https://github.com/mrpossoms) * [mynameisjohn](https://github.com/mynameisjohn)