1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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 <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Marvin Scholz 2024-07-02 20:38:00 +02:00 committed by Michael Niedermayer
parent f2f2b27517
commit 6d9c4bd69e
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -129,7 +129,7 @@ int ff_perlin_init(FFPerlin *perlin, double period, int octaves, double persiste
for (i = 0; i < 256; i++) {
unsigned int random_idx = av_lfg_get(&lfg) % (256-i);
uint8_t random_val = random_permutations[random_idx];
random_permutations[random_idx] = random_permutations[256-i];
random_permutations[random_idx] = random_permutations[255-i];
perlin->permutations[i] = perlin->permutations[i+256] = random_val;
}