Skip to content

Commit 6d9c4bd

Browse files
ePiratmichaelni
authored andcommitted
lavfi/perlin: Fix out of bounds stack buffer write
An incorrect calculation in ff_perlin_init causes a write to the stack array at index 256, which is out of bounds. Fixes: CID1608711 Reviewed-by: Stefano Sabatini <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
1 parent f2f2b27 commit 6d9c4bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libavfilter/perlin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int ff_perlin_init(FFPerlin *perlin, double period, int octaves, double persiste
129129
for (i = 0; i < 256; i++) {
130130
unsigned int random_idx = av_lfg_get(&lfg) % (256-i);
131131
uint8_t random_val = random_permutations[random_idx];
132-
random_permutations[random_idx] = random_permutations[256-i];
132+
random_permutations[random_idx] = random_permutations[255-i];
133133

134134
perlin->permutations[i] = perlin->permutations[i+256] = random_val;
135135
}

0 commit comments

Comments
 (0)