From patchwork Sat Feb 10 17:12:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 7547 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp2170034jai; Sat, 10 Feb 2018 09:12:29 -0800 (PST) X-Google-Smtp-Source: AH8x226dT34+uMIE2mlTBNyEECZo9WhoGDnBOyx2OeRKRKoI+v0xpkpl2py+IV5UEzcTnsCivR3r X-Received: by 10.223.128.169 with SMTP id 38mr5396902wrl.104.1518282749595; Sat, 10 Feb 2018 09:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518282749; cv=none; d=google.com; s=arc-20160816; b=Qah6xrK2mjX7IF55oSek8p62nJWvcobyVVhu5eWxA6Rdko+kDKh8sgtIS73iUmFIMP e25oH9Dp1bTC2swrOjRMtrYIMaazxXipmjIeMEEsONT7s60M2i2QJJ/5YkfBHZm7rcIZ TC8C2l4NcB8xDdutMHcGdiA18s7ZasXM/H1XoLdvDyKP++fySPtLozLLKK9A3uBTzAXD vYeTu62V272JB0gfbichVtfUb2jKBoGv0Mk9Qhn9m287TCvboe9ee3ZAuIXE7BpFSsiL vd5ZQrqPn/VZ6AkH0u+09asv53CtIvi+GFiDhmruo4Jh11EO/LuyRoOAikyJCSz76E0/ Wirg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=DTCOEHkU53NBLB0VPFMkFTFdW9vHqDkiSmRJCx5/ATU=; b=t2jLxRz7SYof2QQnk64iONxPLdrG/dNpXGV191xpZ2QD4ddxHd9ePg3ksQFq6kAm5k ma0Dqv8RxxlSKaSfndkqvJI587Mcv3ZpzE7sVpFNJoeDc5iSpahE/esz+sVo1O+tsv86 LWZBQ2asInXLyl+z2Tk9HX2Wq0f3XpvjEyG+6ApAESnpmWhU9uVZiv9t3/a1hEyiBrDn 4PANHOjt58CsafU8jnvXBstitkn4ZS9H4sVgV7mdg8jmHAgRQysu1pgFyIrJXGtc3HJT zar5HCLEOlFJNa4sC00dU7IblsD8MV/jscgccwtFtINt/QDcOLuxETXbZn5XbX8PwfZc f+wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k30si3647490wrd.30.2018.02.10.09.12.29; Sat, 10 Feb 2018 09:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D34D2689950; Sat, 10 Feb 2018 19:12:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C1B16805C5 for ; Sat, 10 Feb 2018 19:12:07 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2E303E17D6; Sat, 10 Feb 2018 18:12:17 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZeutgdWkpvLC; Sat, 10 Feb 2018 18:12:16 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 48B9AE1132; Sat, 10 Feb 2018 18:12:16 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Feb 2018 18:12:06 +0100 Message-Id: <20180210171206.29686-2-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180210171206.29686-1-cus@passwd.hu> References: <20180210171206.29686-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/concatdec: add support for very long line sizes 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes ticket #6761. Signed-off-by: Marton Balint --- libavformat/concatdec.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 178fac86cb..3e41a62a36 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -24,6 +24,7 @@ #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/timestamp.h" +#include "libavutil/bprint.h" #include "avformat.h" #include "internal.h" #include "url.h" @@ -386,18 +387,18 @@ static int concat_read_close(AVFormatContext *avf) static int concat_read_header(AVFormatContext *avf) { ConcatContext *cat = avf->priv_data; - uint8_t buf[4096]; + AVBPrint bp; uint8_t *cursor, *keyword; - int ret, line = 0, i; + int line = 0, i; unsigned nb_files_alloc = 0; ConcatFile *file = NULL; - int64_t time = 0; + int64_t ret, time = 0; - while (1) { - if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) - break; + av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); + + while ((ret = ff_read_line_to_bprint_overwrite(avf->pb, &bp)) >= 0) { line++; - cursor = buf; + cursor = bp.str; keyword = get_keyword(&cursor); if (!*keyword || *keyword == '#') continue; @@ -473,7 +474,7 @@ static int concat_read_header(AVFormatContext *avf) FAIL(AVERROR_INVALIDDATA); } } - if (ret < 0) + if (ret != AVERROR_EOF && ret < 0) goto fail; if (!cat->nb_files) FAIL(AVERROR_INVALIDDATA); @@ -499,9 +500,11 @@ static int concat_read_header(AVFormatContext *avf) MATCH_ONE_TO_ONE; if ((ret = open_file(avf, 0)) < 0) goto fail; + av_bprint_finalize(&bp, NULL); return 0; fail: + av_bprint_finalize(&bp, NULL); concat_read_close(avf); return ret; }