From patchwork Mon Jul 22 03:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14025 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 F29614498F3 for ; Mon, 22 Jul 2019 06:33:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CA9AA68A730; Mon, 22 Jul 2019 06:33:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFC2A68A4A3 for ; Mon, 22 Jul 2019 06:33:34 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id a15so33629435wmj.5 for ; Sun, 21 Jul 2019 20:33:34 -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:mime-version :content-transfer-encoding; bh=R2KUOajoBbBYffv4LPMeVb/IWChTut7B07sjlYO67xI=; b=uhXa2viBCmjGY1YL2EqRjb8HmplximjbYRzNutfJ0BBN/FSa3e0sXDwO5ApB1uKQ2g pPzaBxvCmgcpkgbaDyKXvVkKJ13kuG4gTTNKZvpQaOn2jZrNF36UXZR2BiL/S4CDEmML n/J3QBAQEvkcJCbEwNivRH+zeO/JB5tBkkxYwXZUdkpVxe1jnDAmZXjF0pACD1au5xfi Nmy3oVEzOTiWP1CqMpPv9EPKu/bj9NRWLM17U4aCVfB5IT3sxYEehSQxSFMAsiFKv3Wo UuwXDD483wYCLJqSBkAZoGiXt2Y+SRHsJrBJE55Lk53rid1yeZCPA3JtNSuFkn2akIaf bQCg== 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:mime-version :content-transfer-encoding; bh=R2KUOajoBbBYffv4LPMeVb/IWChTut7B07sjlYO67xI=; b=P3gRPXSUHOBjs3Z6Q9s9TxlDRhDWago3eXTv1INW4eKIdSaaQcpDUcwJfWXVdiONZc GjdVR/jaq0SnBndW/5ANDmN6D3P0l6aQUTYqvqe+U8d29g6MIEYSrPg6a8qPdHONJGqk ma0x49n0s11E+XcUmRFLnSJkZjwfZI6c0CJJWvL8bIVZYIMsunv39tfDOW4jt3jIRAiW 7zJJwlcMDpISyY2eaRW2bP+71YaV3kV4iuZ90WUp1FbMbb6lV9OFbS5KPh+3qhQ96v32 Dl1neXftU6RN0e9/My63E/SOp2W9YiZdescRKWmCZAjy6j87ig15diWGixoNfgO4l669 E50A== X-Gm-Message-State: APjAAAUjg1QLPY+OrnL/xLP9aoJ0iZ9K1TtDsxGqgcJkaGuhlEu6s6Ih TUvr5LzU/vLgLXKLcQPNoMGO3tF6 X-Google-Smtp-Source: APXvYqxsV5A91tQoHDQibmJo3ZSEio0izWce5zarz0TMWZnN7DWDq0tzJMwUTDSEuh2eBIDr8P8P0g== X-Received: by 2002:a1c:be11:: with SMTP id o17mr60515717wmf.115.1563766059690; Sun, 21 Jul 2019 20:27:39 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id t1sm49233202wra.74.2019.07.21.20.27.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 21 Jul 2019 20:27:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Jul 2019 05:27:12 +0200 Message-Id: <20190722032716.40032-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] h264_mp4toannexb: Remove unnecessary check 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" There can be at most 31 SPS and 255 PPS in the mp4/Matroska extradata. Given that each has a size of at most 2^16-1, the length of the output derived from these parameter sets can never overflow an ordinary 32 bit integer. So use a simple int instead of uint64_t and remove the unnecessary check. Signed-off-by: Andreas Rheinhardt --- libavcodec/h264_mp4toannexb_bsf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index fb3f24ea40..8b2899f300 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -68,7 +68,7 @@ static int h264_extradata_to_annexb(AVBSFContext *ctx, const int padding) { H264BSFContext *s = ctx->priv_data; uint16_t unit_size; - uint64_t total_size = 0; + int total_size = 0; uint8_t *out = NULL, unit_nb, sps_done = 0, sps_seen = 0, pps_seen = 0; const uint8_t *extradata = ctx->par_in->extradata + 4; @@ -91,12 +91,6 @@ static int h264_extradata_to_annexb(AVBSFContext *ctx, const int padding) unit_size = AV_RB16(extradata); total_size += unit_size + 4; - if (total_size > INT_MAX - padding) { - av_log(ctx, AV_LOG_ERROR, - "Too big extradata size, corrupted stream or invalid MP4/AVCC bitstream\n"); - av_free(out); - return AVERROR(EINVAL); - } if (extradata + 2 + unit_size > ctx->par_in->extradata + ctx->par_in->extradata_size) { av_log(ctx, AV_LOG_ERROR, "Packet header is not contained in global extradata, " "corrupted stream or invalid MP4/AVCC bitstream\n");