@ -11,7 +11,7 @@ namespace Exiv2::Internal {
bool isValidBoxFileType(const std::vector<uint8_t>& boxData) {
// BR & MinV are obligatory (4 + 4 bytes). Afterwards we have N compatibility lists (of size 4)
if ((boxData.size() - 8u) % 4u != 0) {
if (boxData.size() < 8 || ((boxData.size() - 8u) % 4u) != 0) {
return false;
}
@ -58,6 +58,11 @@ TEST(Jp2_FileTypeBox, withInvalidBoxDataSizeIsInvalid) {
ASSERT_FALSE(isValidBoxFileType(boxData));
TEST(Jp2_FileTypeBox, withSmallBoxDataSizeIsInvalid) {
std::vector<std::uint8_t> boxData(7); // Minimum size is 8
TEST(Jp2_FileTypeBox, with2CLs_lastOneWithBrandValue_isValid) {
std::vector<std::uint8_t> boxData(16);
// The first 4 bytes correspond to the BR (Brand). It must have the value 'jp2\040'