From patchwork Tue Jan 12 16:49:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roderich Schupp X-Patchwork-Id: 24923 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 050E844B360 for ; Tue, 12 Jan 2021 18:56:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C799968AAD0; Tue, 12 Jan 2021 18:56:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2299E6881D4 for ; Tue, 12 Jan 2021 18:56:29 +0200 (EET) Received: by mail-wm1-f43.google.com with SMTP id y187so2784919wmd.3 for ; Tue, 12 Jan 2021 08:56:29 -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:mime-version :content-transfer-encoding; bh=U7GEoTRMIrkNoiIMaxB8BaPJExC5/TPTvyLGLiL3yBE=; b=YA+7rCMVOrNZRB7Cv+CrfGpeE3S8jFwpfFkY9inPVKSGNveOFB3VLmktgvNJ3oKozg 8TUIkAWGjTfG/7usPC5aW+aMER6jp+PgmGNueZnTP3Poq7ZFhoj362OefT02jWMG9Q5R rat79ajyN0sR1JrNMNQKPtM2SHC2X920ESvswxkQtMWXotifSHUOAvGjlG9U7wTehnWJ y5ZxFOkJ7tXyF87Kbg+iEjQosphmiCrbfknpeg0IgPmomLUuVQzG05Yq15fDvwaXHQ87 9tsOi1QuJQRaSwDqXTjxN3d81N9TLOCBvq2W8TcYrhD2+2wEBKss5TiE2+YXKzfToiZb xXIA== 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=U7GEoTRMIrkNoiIMaxB8BaPJExC5/TPTvyLGLiL3yBE=; b=hvMDeqvZrz28Jnc6C/kCkxHzN80CYueL1m0SY5/f9QjK0IgVuUPKK2HxS+I8S6bwjD UzaXrUgUsxpZWOGYQ+XXpz+ppJSf1I0gbXX03sYx9mhsqj62h6CNd5YqwMOcjsZA8Jzm /QwpNgm6N5Bey1EmWmYruV6N8Br6YCuCQLAMeuhg6nC+ezLIKTqVo3TskMVJZyJE5kE8 gmWRRI9j45nn0G3Fnn8/230xxZYvK//9zMiH0oYfVutTRdN/EtOrNa/7ROaMf0oJXt7W fn7Coo1GHLjCHJwc2SQsZs93k5x9DpYUnaSEIigg6PLBokkB2T/elMV7wtSjIl7dZL7N OC/w== X-Gm-Message-State: AOAM5319ehpihpbvS93Cm8vlRZ47GcVbrqwGdLUiOGz+F2dB8sx1TglG Kr9VvjJIBKqUcR66IIN1PkbNp7wIcjPfKA== X-Google-Smtp-Source: ABdhPJw/SH8s8lHhamdbtDc0eyNyMlDzFTZlrn25j/F21e0E8k6h7x/prbR38SCUN3xZu8P2ncx1kQ== X-Received: by 2002:a1c:220b:: with SMTP id i11mr204731wmi.8.1610470182214; Tue, 12 Jan 2021 08:49:42 -0800 (PST) Received: from nuc8.fritz.box ([2001:a61:2514:5701:c50:937e:d7cf:d183]) by smtp.gmail.com with ESMTPSA id j9sm5599747wrm.14.2021.01.12.08.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 08:49:41 -0800 (PST) From: Roderich Schupp To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Jan 2021 17:49:37 +0100 Message-Id: <20210112164937.7219-1-roderich.schupp@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/webvttdec: Fix WebVTT decoder truncating files at first STYLE block 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: Roderich Schupp Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Bug-ID: 9064 The webvtt decoder truncates the file at the first such block. Since these blocks typically occur at the top of the webvtt file, this results in an empty file (except for the WEBVTT header line). Reason is that at STYLE block neither parses as a valid cue block nor is it skipped like the WEBVTT (i.e. header) or NOTE blocks, hence decoding stops. Solution is to add STYLE to list of skipped blocks. And while we're at it, add REGION, too. --- libavformat/webvttdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c index 8d2fdfe..5a982dd 100644 --- a/libavformat/webvttdec.c +++ b/libavformat/webvttdec.c @@ -89,10 +89,12 @@ static int webvtt_read_header(AVFormatContext *s) p = identifier = cue.str; pos = avio_tell(s->pb); - /* ignore header chunk */ + /* ignore header, NOTE, STYLE and REGION chunks */ if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) || !strncmp(p, "WEBVTT", 6) || - !strncmp(p, "NOTE", 4)) + !strncmp(p, "NOTE", 4) || + !strncmp(p, "STYLE", 5) || + !strncmp(p, "REGION", 6)) continue; /* optional cue identifier (can be a number like in SRT or some kind of