From patchwork Sat Oct 21 20:04:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 5642 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp5115218jah; Sat, 21 Oct 2017 13:04:39 -0700 (PDT) X-Received: by 10.223.166.119 with SMTP id k110mr7053440wrc.182.1508616279242; Sat, 21 Oct 2017 13:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508616279; cv=none; d=google.com; s=arc-20160816; b=gCHkx+d1aLyYCJpg2nWp2t1VKOMK9TkaEkb+0fpuYfldS1jLk+GKhByhwNwCCtcvNY 9hYimJ9CGNld8EMRXi67wnv4UFA9qAlB72alBZR3j851aaWjMOwEUQucT1IaTs9NKsCP 1kNpBIDdLADl1/3LY45xDQ7aIPFWU8bykQ2UPS+X6Azn4COa5EZK7uNlVPvcpJc8Yshm /TrjukBeQJIf4Jk8GWelXM4Y8RZJ2ONi3MvI9K1ZBvRk19+Onxgnc3lCdgUzsoMYcp5B EV4WprjZEy6z2boabg/8t6O2UA+wf/a579eHgXHIjgeqZCMFsUC6jQM1SmZr5w6UeLIQ Hh2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=SiNI7K3hjdQ8sfiOcB4/WaJug0EFCyzFMNPIyD4aaPE=; b=IKOtnGIwcuadLDh+7I+q5E+5ycZTf+BXRuOlTdRPHzT7zVuy9x7BfA6rjacDPgo62n WAJvONusZdyHXqYmpgmjjJ3pKJF1gpysW08Gf2qiiLHx12LMYClWCeO47PfK0fDrASpz kQmzssKIGkL6sdA6br267+Vk58DRiCTBQgbMYSsR+2763MKDYbmIIi9iOk6THo+ilPk0 T3pICLxtUQeruckiWfzARMo24iz8Crglq0IikNHZKFhXbId2osRpmz4v9OnX5I+4EEnF djul8Ojil+aWwLY3YWN2AIG1OYJFQ9jfl50eszVDQMSwOHd/9ZFK/c93aEDPSs+f1oZL sLOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=b2I3OEkP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p10si1153248wmh.117.2017.10.21.13.04.38; Sat, 21 Oct 2017 13:04:39 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=b2I3OEkP; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 23B62689E08; Sat, 21 Oct 2017 23:04:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f179.google.com (mail-io0-f179.google.com [209.85.223.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16E42689988 for ; Sat, 21 Oct 2017 23:04:25 +0300 (EEST) Received: by mail-io0-f179.google.com with SMTP id 97so16423383iok.7 for ; Sat, 21 Oct 2017 13:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=6NVzlH0TOOXINud1t6noNIMoFI1+PdNFcMviUb+92KA=; b=b2I3OEkPCLrU3XTdlt20yhUq220L1MSQTDHo8Nub+OOIG7GaS9R+vnuXX0Qk4rjASV MgN+1DQj7QqCOr3M/OoCqqnDEswOrmXrx6TOhnVPWFeL1kucd7NcNyMwaFy7JTJx6e4K 67slV1eNh6u0SIMpL31zencbL2vbxw47eGrELAp169wiHGx3UaF79uuxTtSuYxme2qtz ZBlAlWqfGCyy5q7UTPdeE43Zjk7Hnv00ap1s9PBzgWaAOUNpc5KOlkOMD3TvGWX42dP2 JzPgi9CMHVCqQMvhXNmQN6gtfe0nEhNbgcn+i6B2tZXWWcjLtApS36CIw/QUs3HZmnZE 4q4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=6NVzlH0TOOXINud1t6noNIMoFI1+PdNFcMviUb+92KA=; b=dvxuEpOzImAhCDTNqc4JcDkYHgb7bORWp0rwRXTZJ1+b/k23vcib0Wy0dYJjxJFcmm 8SvxWztio8jKWA0z/xmdOB4AAD1PXuUbsWrTLKHsyuQ156MovoGQ2jWN3/5uJ+i00jPq twD9YoAwd+ArMYQ4i6QYeSgh32G3SVJ002sSWHIIYIF+91wNLKLVslD16MnGa/dIsETa dhZRDF6Ym0Z3Q9o+gtYQ1L2yrikZzEk029uom+rVWbCCK4VOM018e12YweEr+MfG21dz CFZ6TZiHqVE2H5hC1zGdVVEXHpQIChcw0pe3CwKH8bumMchB2SoNEJrZy8h/1MbMqFWM CpKA== X-Gm-Message-State: AMCzsaX3BPyV0S+391u/rc/NJLQCd0rKQzQVVVeA8NgzCXFIkPreWBYO kuLU+oNFkLLmbdl+APOyAEHdegBKUPKHmHkePLA= X-Google-Smtp-Source: ABhQp+SAGP0ux2uOtTsuk6E3QUieu88P00wasq28Z7mKKNR/dV1hfbecgZxZFTJBZJXTDyT+ObGjWGMsDl00bJHruHY= X-Received: by 10.107.138.222 with SMTP id c91mr2984356ioj.246.1508616270069; Sat, 21 Oct 2017 13:04:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.63.101 with HTTP; Sat, 21 Oct 2017 13:04:09 -0700 (PDT) In-Reply-To: <20171021162944.GA195910@phare.normalesup.org> References: <20171021162944.GA195910@phare.normalesup.org> From: Carl Eugen Hoyos Date: Sat, 21 Oct 2017 22:04:09 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH]lavf/concatdec: Allocate the filenames on the heap 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2017-10-21 18:29 GMT+02:00 Nicolas George : > Le decadi 30 vendémiaire, an CCXXVI, Marton Balint a écrit : >> I thought filenames in libavformat are limited to 1K anyway >> because of the AVFormatContext->filename field. How can I reproduce this? I tested the data from the ticket from the command line and it worked fine here. Or is there maybe no limitation for the data protocol? >> So if your patch really fixes the ticket, then how? :) So the original (and the attached) patch do not fix the ticket for you? Could you provide some console output to allow me to better understand the issue? > Yes, exactly. This limitation was the reason I did not bother handling > longer lines. I would like to understand how it makes a difference. New patch attached, please comment. Carl Eugen From aa8ff422cfe1d7753f9a90cfbbefe1c02ebf5091 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 21 Oct 2017 22:02:52 +0200 Subject: [PATCH] lavf/concatdec: Allocate the filenames on the heap. Allow huge filenames, real-world content can be passed via data: protocol. Fixes ticket #6761. --- libavformat/concatdec.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 0e18901..b0075ce 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -386,16 +386,24 @@ static int concat_read_close(AVFormatContext *avf) static int concat_read_header(AVFormatContext *avf) { ConcatContext *cat = avf->priv_data; - uint8_t buf[4096]; - uint8_t *cursor, *keyword; + int buf_size = 50002; + uint8_t *buf, *cursor, *keyword; int ret, line = 0, i; unsigned nb_files_alloc = 0; ConcatFile *file = NULL; int64_t time = 0; + buf = av_malloc(buf_size); + if (!buf) + return AVERROR(ENOMEM); + while (1) { - if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) + if ((ret = ff_get_line(avf->pb, buf, buf_size)) <= 0) break; + if (ret == buf_size - 1) { + av_log(avf, AV_LOG_ERROR, "filename too long (>%d)\n", buf_size - 2); + FAIL(AVERROR_INVALIDDATA); + } line++; cursor = buf; keyword = get_keyword(&cursor); @@ -499,9 +507,11 @@ static int concat_read_header(AVFormatContext *avf) MATCH_ONE_TO_ONE; if ((ret = open_file(avf, 0)) < 0) goto fail; + av_freep(&buf); return 0; fail: + av_freep(&buf); concat_read_close(avf); return ret; } -- 1.7.10.4