[FFmpeg-devel] avcodec/pgssubdec: Check for duplicate display segments

Submitted by Michael Niedermayer on Jan. 29, 2019, 12:32 a.m.

Details

Message ID 20190129003217.11578-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 29, 2019, 12:32 a.m.
In such a duplication the previous gets overwritten and leaks

Fixes: memleak
Fixes: 12510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGSSUB_fuzzer-5694439226343424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/pgssubdec.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer Feb. 3, 2019, 6:42 p.m.
On Tue, Jan 29, 2019 at 01:32:17AM +0100, Michael Niedermayer wrote:
> In such a duplication the previous gets overwritten and leaks
> 
> Fixes: memleak
> Fixes: 12510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGSSUB_fuzzer-5694439226343424
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/pgssubdec.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index b897d72aab..8c10f6d573 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -676,6 +676,11 @@  static int decode(AVCodecContext *avctx, void *data, int *data_size,
              */
             break;
         case DISPLAY_SEGMENT:
+            if (*data_size) {
+                av_log(avctx, AV_LOG_ERROR, "Duplicate display segment\n");
+                ret = AVERROR_INVALIDDATA;
+                break;
+            }
             ret = display_end_segment(avctx, data, buf, segment_length);
             if (ret >= 0)
                 *data_size = ret;