Audit finding
- ID:
AUD-009
- Status: Verified defect
- Severity: High
- Confidence: High
- Audited revision:
2f479320d805a1f9f35ebe4afaaeeded48913a94
Problem
The DWT requires positive N and Levels but does not require N to be divisible by 2^Levels. It also exposes synthesis filters but SynthesisStep() reads the analysis filters instead.
Source:
|
{ |
|
static_assert(std::is_floating_point_v<T>, "DiscreteWaveletTransform supports floating-point types only"); |
|
static_assert(N > 0, "DiscreteWaveletTransform N must be > 0"); |
|
static_assert(Levels > 0, "DiscreteWaveletTransform Levels must be > 0"); |
|
static_assert(Taps >= 2, "DiscreteWaveletTransform Taps must be >= 2"); |
|
|
and
|
{ |
|
T sumA{ 0 }; |
|
T sumD{ 0 }; |
|
for (std::size_t i = 0; i < half; ++i) |
|
{ |
|
std::size_t fIdx = (n + outLen - 2 * i) % outLen; |
|
if (fIdx < Taps) |
|
{ |
|
sumA += filters.lowAnalysis[fIdx] * ca[i]; |
|
sumD += filters.highAnalysis[fIdx] * cd[i]; |
|
} |
|
} |
|
out[n] = sumA + sumD; |
|
} |
|
} |
|
|
|
template<typename T, std::size_t N, std::size_t Levels, std::size_t Taps> |
|
OPTIMIZE_FOR_SPEED void DiscreteWaveletTransform<T, N, Levels, Taps>::Forward(const Signal& x, Signal& coeffs) |
|
{ |
|
coeffs.clear(); |
|
coeffs.resize(N, T{ 0 }); |
|
|
|
for (std::size_t i = 0; i < N; ++i) |
Reproduction
DiscreteWaveletTransform<float, 3, 1, 2> constructs and performs forward transform, then inverse reconstruction aborts on an internal bounded-vector access.
Acceptance criteria
Audit finding
AUD-0092f479320d805a1f9f35ebe4afaaeeded48913a94Problem
The DWT requires positive
NandLevelsbut does not requireNto be divisible by2^Levels. It also exposes synthesis filters butSynthesisStep()reads the analysis filters instead.Source:
numerical-toolbox-cpp/numerical/analysis/DiscreteWaveletTransform.hpp
Lines 81 to 86 in 2f47932
numerical-toolbox-cpp/numerical/analysis/DiscreteWaveletTransform.hpp
Lines 159 to 181 in 2f47932
Reproduction
DiscreteWaveletTransform<float, 3, 1, 2>constructs and performs forward transform, then inverse reconstruction aborts on an internal bounded-vector access.Acceptance criteria
N/Levelsat compile time.