From patchwork Mon Dec 9 22:26:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16686 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 567CA44AA6E for ; Tue, 10 Dec 2019 00:34:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36AE468B738; Tue, 10 Dec 2019 00:34:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 173B668B0A2 for ; Tue, 10 Dec 2019 00:34:02 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id d16so17896877wre.10 for ; Mon, 09 Dec 2019 14:34:02 -0800 (PST) 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=+XbDNM1wUfjlUyaH7JucOUhRIpEhA3lVhsmOtwdEnPU=; b=gdfpZV0yye4CpeIfF18RWNn2RTZCJzo7a/L5TrA4nkFwMPUu2PdGrOcTYq1Zwi6SKu ou7Q6XJnp8I9BbU0KOvmcZMZsIvqMB3u9SWfNr6YIwTeC5KkELuArCxFvuUsSiUvjV2k YMnfhpUluSeikfP1W6o3vZYtYyeQGMkNbeWtLfDBDwbkulCMh5/pCV+FF6d5Uq2kKSlJ Es/YBzFX8mrqlsCpHLxdpcAu0HGFLh5dfafMyZHjWdsgndt0fs2fWb5Wa5GgYFTgyKA2 por1evPVBHpTnGTFOZ9/kYGEvyv6aiT0T8nMkcfZYMJg8O/jgoAR1ZFF968IcBOSV4Ld gtcQ== 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=+XbDNM1wUfjlUyaH7JucOUhRIpEhA3lVhsmOtwdEnPU=; b=IlCAh3KXmpZmcrFWgcQPFDdDua+ANI85KMeICMS+hfyO6SMUJ5BTeIkZBWWjKTzCyr tEcDJiPdzrWUqb/qa0NXnO4GwzbX3gk1A3JzTYkY2t3NMErzy+qSF1xLUrozx7mB2NDm A8tgCZp7gb2QszcUAlgFJnBeUjikqz8vRh+qpwJ1iT6tAth6kvBCf+EOopz4wTwPvQzC kRImm3zelncZJmXNbAcr7IJcFT2gw7KL62Imve8n4dGhB8Nv4cG4C3zo+LXYOrjzLcf2 RMVpMWUwlzngAJsAZVMizTbV6OUpKNaWCutnQLt/K025fEg9SOSEtibur/5/kJbMag4u 0SiA== X-Gm-Message-State: APjAAAUhjFCsFlxMu2gSaj3jBohHf4V2u/TPT8uiRMAUSt8yMzu3jmWM fEaOnMGXo3vf2d901H90TAgckjkh X-Google-Smtp-Source: APXvYqy4ICdN/MSAEqj4rqdfPMNGIvcucsbaxfyn+J0Z7/yTJQW68l5xXkS66sT342Nfi+tV+sB9zg== X-Received: by 2002:a5d:6144:: with SMTP id y4mr4569057wrt.15.1575930841396; Mon, 09 Dec 2019 14:34:01 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08e23.dynamic.kabel-deutschland.de. [188.192.142.35]) by smtp.gmail.com with ESMTPSA id v22sm865893wml.11.2019.12.09.14.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 14:34:00 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Dec 2019 23:26:03 +0100 Message-Id: <20191209222604.28920-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191209222604.28920-1-andreas.rheinhardt@gmail.com> References: <20191209222604.28920-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] avcodec/cbs_h2645: Treat slices without data as invalid 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" Slices that end after their header (meaning slices after the header without any data before the rbsp_stop_one_bit or possibly without any rbsp_stop_one_bit at all) are invalid and are now dropped. This ensures that one doesn't run into two asserts in cbs_h2645_write_slice_data(). Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs_h2645.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index be82a8cd5f..c66876ea06 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -855,6 +855,9 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx, if (err < 0) return err; + if (!cbs_h2645_read_more_rbsp_data(&gbc)) + return AVERROR_INVALIDDATA; + pos = get_bits_count(&gbc); len = unit->data_size; @@ -1030,6 +1033,9 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx, if (err < 0) return err; + if (!cbs_h2645_read_more_rbsp_data(&gbc)) + return AVERROR_INVALIDDATA; + pos = get_bits_count(&gbc); len = unit->data_size;