From patchwork Mon Jan 14 23:25:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 11755 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 0BC4744DBD0 for ; Tue, 15 Jan 2019 01:25:24 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2465C68A933; Tue, 15 Jan 2019 01:25:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A1ED68A8D4 for ; Tue, 15 Jan 2019 01:25:05 +0200 (EET) Received: by mail-io1-f67.google.com with SMTP id m19so666788ioh.3 for ; Mon, 14 Jan 2019 15:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=erx1C6Bg9kV/QpJaCpgSpoGK0FSCAkhV9StoBLI3yXw=; b=s3RHQiHB+z7Gtg6HpqexhUw16iopW7kiXcTRpNNaGW1iFaMrfE3Dt91qoDFHckAofx jrGkoN4Kj6+h+ZmZ+q1a7TOP2OC3jcyNcVG4vUveQKi7/xWYvwiq6P9kuVy+UjeHUikA hyI3dj5tDYyIFlp98IFM77z6dBFjuJ/IOryMrLvKIDh7K+EGnnLqfqx+Efum7OSPbWXc i5RWkk/JhzrckWFcAe35NAgXEI1E3ygMBjErD4ZoXR8bcrXmPXsJy0gV/ETssPKJ9tmD 1aazM4zbeAkbAFiB8YKwXo+QLUOen+pmBhKjoF5gjFBNDogJlVy48gYlJoWPuAP7U2xx r4cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=erx1C6Bg9kV/QpJaCpgSpoGK0FSCAkhV9StoBLI3yXw=; b=dDIOSzYPNenUAwBgD3zdp5r+d/wQHCw1d3AWogTQu7FxhraYbfVk9jMJew3UF70Q1z HbmphwWdKYjpdIneY/06zS0eyPBSaOCnUboLT7iDeLk8tY6HarCg2yegYDhvvqIubgfV gXNBDdQne8J72gBH/6RThT6kpGDPxkOoKpZQZqiaV99LhHDvQA9DDFbta3m8kmndCPLq gA3veATuqnA7KBXzuz6SLbe1GQBfUrMTmuR5b3HfwTBd5MHlWnxrk7yTCJ1o7mfKEdl9 PDhBRf2QNJCDUJtMAkr00XORoV9HynoTk9EvekIzaiHFtOfbOdnmJ73OYD9aLWPsKJ5W vcYA== X-Gm-Message-State: AJcUukdBnT+TDYODLeyhReIf1hMqSCzitLsEzJ9EhHEoYD/A15O2wCRg 8PE4LWVAK4L0vPZ+XluBcVY384djtXS1nUtjgi87Vg== X-Google-Smtp-Source: ALg8bN6teC3kPlFXe5zwvW4BL6K4HTcQ3MRgHrE2sEWxZCOxYcIHmjjvr7t6+dewhZpIOdAMxOR+jfWWaeel016TBOs= X-Received: by 2002:a5e:9707:: with SMTP id w7mr539204ioj.49.1547508317951; Mon, 14 Jan 2019 15:25:17 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:5f11:0:0:0:0:0 with HTTP; Mon, 14 Jan 2019 15:25:17 -0800 (PST) From: Carl Eugen Hoyos Date: Tue, 15 Jan 2019 00:25:17 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavf/cafdec: Do not fail hard for files ending with junk 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" Hi! A user provided a real-life caf file ending with junk after the data chunk, QuickTime reads such files. Please comment, Carl Eugen From 67d49072d60b95ffc8838a20cb87b33b5904dc21 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 15 Jan 2019 00:22:50 +0100 Subject: [PATCH] lavf/cafdec: Do not fail hard if the file ends with junk. QuickTime does not fail if the file contains random data after the data chunk. --- libavformat/cafdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 7652d9e..20956bc 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -310,6 +310,8 @@ static int read_header(AVFormatContext *s) "skipping CAF chunk: %08"PRIX32" (%s), size %"PRId64"\n", tag, av_fourcc2str(av_bswap32(tag)), size); case MKBETAG('f','r','e','e'): + if (size < 0 && found_data) + goto found_data; if (size < 0) return AVERROR_INVALIDDATA; break; @@ -325,6 +327,7 @@ static int read_header(AVFormatContext *s) if (!found_data) return AVERROR_INVALIDDATA; +found_data: if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) { if (caf->data_size > 0) st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet; -- 1.7.10.4