`blocklength` should be bigger than `3` (channel count)
`byteoffset` should not be bigger than `2` (does not make sense as per the
last loop)
`src` should not overlap with `dst`.
There is no allocation in this function so it should be safe to return
early.
Security: GHSA-9qqv-q4qw-mf8m
uint8_t *src, *dst;
uint32_t i, j;
- if (blocklength > PROGRAM_WORK_SIZE / 2 || stride > blocklength)
+ if (blocklength > PROGRAM_WORK_SIZE / 2 || stride > blocklength || blocklength < 3 || byteoffset > 2)
return 0;
src = &vm->memory[0];
uint8_t *prev = dst + i - stride;
for (j = i; j < blocklength; j += 3)
{
+ /*
+ * The src block should not overlap with the dst block.
+ * If so it would be better to consider this archive is broken.
+ */
+ if (src >= dst)
+ return 0;
+
if (prev >= dst)
{
uint32_t delta1 = abs(prev[3] - prev[0]);