From patchwork Sun Jul 19 20:47:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21195 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C984F44B520 for ; Sun, 19 Jul 2020 23:48:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B292868B98E; Sun, 19 Jul 2020 23:48:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3C6168B975 for ; Sun, 19 Jul 2020 23:48:27 +0300 (EEST) Received: by mail-ej1-f48.google.com with SMTP id lx13so16074996ejb.4 for ; Sun, 19 Jul 2020 13:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wokC8fv1VqdqHJEcdWUR7aX514WOndkM6Imt0qtxWOo=; b=A4ALqt7bdqPOcP2YVSoNHDxl++jfNryq3yWOdiujD+D6tSiT7RI9tFDI/3Ud9iKE3B AcECEYSM5S6iT2RplrhR9s6K1NtaFV5OheaGPnDWAwKtBi8PW0rBVQB/CxGIr/eUdCVI xaNdxMIJrW6NEw+mTPXgWlojMq1fhmGFvbDzgr+HnDeQvIKEKICs8DWnuSy8FjkLwZPO rv2xoeBkpWcHZUZIL0o46iYpf34cldAbeENz3qEPEIjZVCIqhfEUtUxZZYwS/Q7z6nx8 MB3QRy7VBitaYMS+4lrKC0DDuVST65dnGQ6vYb3zac5GKWLBdIsdSeEgJUYiEycjIY89 5fSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wokC8fv1VqdqHJEcdWUR7aX514WOndkM6Imt0qtxWOo=; b=otUUcfqIs+ECuHBtLBMVdKsOBi8jzBUM4l8GHQDomoU4vEKrAQDhVQWZ5yLzA6Bj9n pIHjaoOLtE0qQmop72OH4lOVJF4dJQsf5TH1cs3OPGunCozkvJopZlRzRM2RkXzQAARm xaRsj46AHreCw6ayXifAYBJYaV1Zetkvc0GYrARkymPUcUfTPbWI+RoHTod72jEn+480 bJ4VwBN60o4ZcnN3aNlonX784lRz7xRzUlsrmlc8VpJO3Nh790qPOeyLKnjhFUWkY8U4 owXGOJdnLt6DXfgTDtH4Zp8V35Gal0UaGEejGsz/AoaGguz0S6Zqc3D3gGcG5J5AM7KU 1Vlg== X-Gm-Message-State: AOAM530BIsHpXYtKOP5vOEeEuf/WjtfkPp7mG6Zo3AHC7pO5Wo1XT0WB nctwRi81sHBZ9OpgwtO9P3BAK5Gp X-Google-Smtp-Source: ABdhPJzXcDPf4+8Yd/v6AjHz+va5JXrUOB8vcDG+7UWgikKGS83cb2Cc7VOaJmySaHGy7VBFHhjunQ== X-Received: by 2002:a17:907:6fc:: with SMTP id yh28mr17740710ejb.267.1595191706697; Sun, 19 Jul 2020 13:48:26 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id hb8sm13421913ejb.8.2020.07.19.13.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2020 13:48:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Jul 2020 22:47:55 +0200 Message-Id: <20200719204755.32269-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200719204755.32269-1-andreas.rheinhardt@gmail.com> References: <20200719204755.32269-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/wc3movie: Fix memleak upon read_header failure X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" wc3_read_header() might fail after having read some data into a packet in which case this data would leak. Fix this by setting the AVFMT_HEADER_CLEANUP flag that ensures that the demuxer's read_close function is called (it unrefs the packet) if reading the header failed. Fixes: memleak Fixes: 23660/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6007508031504384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Andreas Rheinhardt --- Michael, can you confirm that this fixes the memleak? libavformat/wc3movie.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index 6577007777..ebe2196052 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -299,6 +299,7 @@ static int wc3_read_close(AVFormatContext *s) AVInputFormat ff_wc3_demuxer = { .name = "wc3movie", .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III movie"), + .flags = AVFMT_HEADER_CLEANUP, .priv_data_size = sizeof(Wc3DemuxContext), .read_probe = wc3_probe, .read_header = wc3_read_header,