From patchwork Thu Dec 13 12:09:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 11402 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 D098844E2D6 for ; Thu, 13 Dec 2018 14:09:40 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECA5768A912; Thu, 13 Dec 2018 14:09:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBEA068A6A0 for ; Thu, 13 Dec 2018 14:09:34 +0200 (EET) Received: by mail-wm1-f53.google.com with SMTP id n190so2123818wmd.0 for ; Thu, 13 Dec 2018 04:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=BsSNE6d3O6vRpFQvbj/x0gPaonfyJgR89ZQ/Dpr3G8k=; b=lWmA05KAgpe/9mSPhaUN/2dD3S92oLIgRMII4BbvXVAz+KNQYkXVyDlFWDimgPXMJx GskyjW9ai6NUGdGPH7rPhy9PvV9WWdinBlc8ZbxL2SEEBZOTnNPaNgL7AXaSQgY1nd7n hwp71KRwINozr6gH/3hdZYPz1BYSJrJ8z5LCq7dUEGoRCvn+8tf8eu5wwwnhC4DMab2q wjFtiMd4dlMbYp/RnCXQ8fS+CyUlL7bQ0leBbH37BweaIZFKPLMIBGYVP/cOXtAeiqwh TdfuGb0D4Xf7lZKewZ9qb3dYzcGBFAd6Ei8dJYWdiLKMxsEgVBBEh0GGQAYpOgaiWTRh LI2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=BsSNE6d3O6vRpFQvbj/x0gPaonfyJgR89ZQ/Dpr3G8k=; b=T7DOILqNDFLI53BSJn4rqjkR+hj6uRggCkuHruPO9NhdmShvMT1VDrtHYSqyQ89YXS a62YJUQkMOdMLcsnyvxOd0zvNlXehHWb9hwrjIUggQ50hlKo4QBi8w9CbN1ImvwV+S4C rxER3X31BVsYZuAzPSYJ/Sx4j2S2E+h2bzsr4rukRr3v1hgypeoW+dD2IXPcUbWQnrNG ajGCk7F7u2Wnq1/EYbbJTG+NPtb3jo5qzA2LRPqiw7jrC0tzIfUWiMly7Lej/DsoIoJe 7cVpflwh5ZA4fxrxEBtsSnw+GYOuVNPAD7Ek/qbxIgJ7vZwaXGgzX2B/ArXO5CvKxuD8 MLqA== X-Gm-Message-State: AA+aEWaDVXowZUS87mCtvbyCFvdIxB6/ejlKFbycIaIjTxIENl6yvg0L rsFRtklKXj+GJLavqa+sggKpvdJy X-Google-Smtp-Source: AFSGD/XkWpNtQPzJws6t/wlyFSFIA9KnqGbopVoJKPymKgaoh7GbRQpdgAVl6zMeN6nsN6c4oXmhxg== X-Received: by 2002:a1c:dd04:: with SMTP id u4mr9918459wmg.84.1544702973833; Thu, 13 Dec 2018 04:09:33 -0800 (PST) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id n15sm2075243wrt.21.2018.12.13.04.09.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 04:09:33 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Dec 2018 13:09:25 +0100 Message-Id: <20181213120925.14531-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avformat/ffmetadec: do no limit size of tags to 1024 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Use bprint API instead. Fixes #4833. Signed-off-by: Paul B Mahol --- libavformat/ffmetadec.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index 3290b3b7bc..5427e67c54 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/bprint.h" #include "libavutil/mathematics.h" #include "avformat.h" #include "ffmeta.h" @@ -32,6 +33,15 @@ static int probe(AVProbeData *p) return 0; } +static void get_bprint_line(AVIOContext *s, AVBPrint *bp) +{ + + do { + av_bprint_clear(bp); + ff_read_line_to_bprint(s, bp); + } while (!avio_feof(s) && (bp->str[0] == ';' || bp->str[0] == '#' || bp->str[0] == 0)); +} + static void get_line(AVIOContext *s, uint8_t *buf, int size) { do { @@ -128,12 +138,14 @@ static int read_tag(const uint8_t *line, AVDictionary **m) static int read_header(AVFormatContext *s) { AVDictionary **m = &s->metadata; - uint8_t line[1024]; + AVBPrint bp; + + av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); while(!avio_feof(s->pb)) { - get_line(s->pb, line, sizeof(line)); + get_bprint_line(s->pb, &bp); - if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) { + if (!memcmp(bp.str, ID_STREAM, strlen(ID_STREAM))) { AVStream *st = avformat_new_stream(s, NULL); if (!st) @@ -143,7 +155,7 @@ static int read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_FFMETADATA; m = &st->metadata; - } else if (!memcmp(line, ID_CHAPTER, strlen(ID_CHAPTER))) { + } else if (!memcmp(bp.str, ID_CHAPTER, strlen(ID_CHAPTER))) { AVChapter *ch = read_chapter(s); if (!ch) @@ -151,9 +163,11 @@ static int read_header(AVFormatContext *s) m = &ch->metadata; } else - read_tag(line, m); + read_tag(bp.str, m); } + av_bprint_finalize(&bp, NULL); + s->start_time = 0; if (s->nb_chapters) s->duration = av_rescale_q(s->chapters[s->nb_chapters - 1]->end,