Coverage Report

Created: 2026-05-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/exiv2/src/jp2image_int.cpp
Line
Count
Source
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
3
#include "jp2image_int.hpp"
4
5
#include "types.hpp"
6
7
#include <cassert>
8
#include <cstdint>
9
#include <vector>
10
11
namespace Exiv2::Internal {
12
13
186
bool isValidBoxFileType(const std::vector<uint8_t>& boxData) {
14
  // BR & MinV are obligatory (4 + 4 bytes). Afterwards we have N compatibility lists (of size 4)
15
186
  if (boxData.size() < 8 || ((boxData.size() - 8u) % 4u) != 0) {
16
10
    return false;
17
10
  }
18
19
176
  const size_t N = (boxData.size() - 8u) / 4u;
20
176
  const uint32_t brand = getULong(boxData.data(), bigEndian);
21
176
  const uint32_t minorVersion = getULong(boxData.data() + 4, bigEndian);
22
23
176
  bool clWithRightBrand = false;
24
959
  for (size_t i = 0; i < N; i++) {
25
876
    uint32_t compatibilityList = getULong(boxData.data() + 8 + (i * 4), bigEndian);
26
876
    if ((brand == brandJp2 && compatibilityList == brandJp2) || (brand == brandJph && compatibilityList == brandJph)) {
27
93
      clWithRightBrand = true;
28
93
      break;
29
93
    }
30
876
  }
31
176
  return (minorVersion == 0 && clWithRightBrand);
32
186
}
33
}  // namespace Exiv2::Internal