From patchwork Wed Jun 24 13:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20577 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 B69A544B3C4 for ; Wed, 24 Jun 2020 16:53:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A13426801E0; Wed, 24 Jun 2020 16:53:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 728D368B5C8 for ; Wed, 24 Jun 2020 16:53:44 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id o11so2360582wrv.9 for ; Wed, 24 Jun 2020 06:53:44 -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=XjnFVZHrAaW584X5qN4LfjV2jroT102VA7wAipdZ8do=; b=Yru8CNHCVP0PY50zH5iVeVIofS6Cpt7Vk6otbcOuQgjX1W0qZufVme+xOniZkKlHav F1QU5GDum2+Ix4+AcfrLkbgrEX8u6HES/sWosDhankvVWjTT++pBfBUYhhfYYQPoruFC EvK7INaTBoTEUGsu7vFyPu5qAJLOu8n+fla2+5qeJYXiZ0i1fKmoq2jMyZuWJrJehWNJ GlbG6NS3afVHYFNExUSfEmDOu3tSySs/xeq+ze7Rc6baqyPZcowjaej2esfuElhMpAzE Aazt+Buw5xXiXyDi8S0JupNy3i1YMHMjBstM6fJy22YB5CAT2R7f/eQZ0dPU+t/XyJyC QZ+w== 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=XjnFVZHrAaW584X5qN4LfjV2jroT102VA7wAipdZ8do=; b=H4yZUyNLRAZ0qUvqCUB1in2TbOBuz4CwyKgQKAo3WNd1VOjOt2cyvy31pbmdOZP63t z9gUaaaW/5rHdwDeCaJ3LDFX3e+IlBg42jb3XyHowoBslK/O12G1EqLSqJlzBWySFUYw vQOVvoX6EkOGhEgZ3x0NYJt+AO2px+U3MLdhR2Hkf3a8X/eT651vLmX2GAfRWq7u17IZ FwQrFMGeqwE66HmyjwDx0K2XYnTCb+zFc/LVJ8iXQPoD+GJx3hW7bwnCKNIU8sLAFtmO iHneNw+bdyD5WZz4PuAX6JyUQ1sBYb+VDrzcm7ccbA0BLjvPbpwUXYiSfySGzoMo9OUW Tryg== X-Gm-Message-State: AOAM531VZy8JCHKG83TOAzIcDLnT6TzKigH4YGHteaOyLOY8wnTpN6SR sPa2ZXurUrvmkNG5g+zvbOYtr5Ao X-Google-Smtp-Source: ABdhPJyvBsgDpusJXq+Oekmj3GnzorJESSaAzRKDChs+PGFg7WRWsS+NIlPgTvLtnhpCeJGrqDszmQ== X-Received: by 2002:adf:f450:: with SMTP id f16mr31526837wrp.307.1593006823682; Wed, 24 Jun 2020 06:53:43 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id y25sm8172390wma.19.2020.06.24.06.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 06:53:42 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jun 2020 15:46:59 +0200 Message-Id: <20200624134705.14833-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200624134705.14833-1-andreas.rheinhardt@gmail.com> References: <20200624134705.14833-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] avformat/smacker: Check audio frame size 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" The first four bytes of smacker audio are supposed to contain the number of samples, so treat audio frames smaller than that as invalid. Signed-off-by: Andreas Rheinhardt --- libavformat/smacker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 787c5d8972..c803ecbec9 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -307,14 +307,14 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) if(flags & 1) { uint32_t size; - size = avio_rl32(s->pb) - 4; - if (!size || size + 4LL > frame_size) { + size = avio_rl32(s->pb); + if ((int)size < 8 || size > frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); ret = AVERROR_INVALIDDATA; goto next_frame; } frame_size -= size; - frame_size -= 4; + size -= 4; if ((ret = av_reallocp(&smk->bufs[smk->curstream], size)) < 0) { smk->buf_sizes[smk->curstream] = 0; goto next_frame;