Skip to content
Snippets Groups Projects
Commit 7dd836a3 authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

avcodec/qtrle: Check remaining bytestream in qtrle_decode_XYbpp()

Fixes: Timeout
Fixes: 9213/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QTRLE_fuzzer-5649753332252672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg


Signed-off-by: default avatarMichael Niedermayer <michael@niedermayer.cc>
parent 2de5209d
No related branches found
No related tags found
No related merge requests found
...@@ -155,6 +155,8 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr, ...@@ -155,6 +155,8 @@ static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr,
CHECK_PIXEL_PTR(0); CHECK_PIXEL_PTR(0);
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) { while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
if (bytestream2_get_bytes_left(&s->g) < 1)
return;
if (rle_code == 0) { if (rle_code == 0) {
/* there's another skip code in the stream */ /* there's another skip code in the stream */
pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->g) - 1)); pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->g) - 1));
...@@ -210,6 +212,8 @@ static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change) ...@@ -210,6 +212,8 @@ static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
CHECK_PIXEL_PTR(0); CHECK_PIXEL_PTR(0);
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) { while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
if (bytestream2_get_bytes_left(&s->g) < 1)
return;
if (rle_code == 0) { if (rle_code == 0) {
/* there's another skip code in the stream */ /* there's another skip code in the stream */
pixel_ptr += (4 * (bytestream2_get_byte(&s->g) - 1)); pixel_ptr += (4 * (bytestream2_get_byte(&s->g) - 1));
...@@ -259,6 +263,8 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change ...@@ -259,6 +263,8 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change
CHECK_PIXEL_PTR(0); CHECK_PIXEL_PTR(0);
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) { while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
if (bytestream2_get_bytes_left(&s->g) < 1)
return;
if (rle_code == 0) { if (rle_code == 0) {
/* there's another skip code in the stream */ /* there's another skip code in the stream */
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 2; pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 2;
...@@ -303,6 +309,8 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change ...@@ -303,6 +309,8 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
CHECK_PIXEL_PTR(0); CHECK_PIXEL_PTR(0);
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) { while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
if (bytestream2_get_bytes_left(&s->g) < 1)
return;
if (rle_code == 0) { if (rle_code == 0) {
/* there's another skip code in the stream */ /* there's another skip code in the stream */
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 3; pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 3;
...@@ -350,6 +358,8 @@ static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change ...@@ -350,6 +358,8 @@ static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change
CHECK_PIXEL_PTR(0); CHECK_PIXEL_PTR(0);
while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) { while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
if (bytestream2_get_bytes_left(&s->g) < 1)
return;
if (rle_code == 0) { if (rle_code == 0) {
/* there's another skip code in the stream */ /* there's another skip code in the stream */
pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 4; pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 4;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment