From patchwork Sat Jul 6 16:59:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13838 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 EAB564469A7 for ; Sat, 6 Jul 2019 20:02:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C4A3768AAA2; Sat, 6 Jul 2019 20:02:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D90F68974C for ; Sat, 6 Jul 2019 20:02:42 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id z1so8182030wru.13 for ; Sat, 06 Jul 2019 10:02:42 -0700 (PDT) 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=aFPLP6UCCoaMMWmZlOES2EpZGXz5QbE1fhB2R6aQsEQ=; b=L8LVyIIcSMe2MNUXpQqnK3fEvhfNcn/eVLlbZM/DVIedKtdwnj21mpmxw87o3NkIOg fLedQLkYV22NPqWne1CLXm38A7LcGMw+dZll5EkjpDLPvHkcHQF9dKiXCGUpaTfrR5QH 5LpzUFBOY2SOIXb6EYQsy1HLZSgIy+sGeWscwO1d8zwWzeT2jMpukEtzw7YbHbFH8SPG WDPUH6SaAVpZKSODePbgAe9mcIhK/2edWiJv4FoqfhtDISfBk7QkTo7X9ces4W/UXD9L WUVZGmQIxaf7wLv0UNGm845zUq9/GJ2+ckrn5NA3DhSfJab9EdfMq4vUc4bnKTEXPpf1 yhig== 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=aFPLP6UCCoaMMWmZlOES2EpZGXz5QbE1fhB2R6aQsEQ=; b=Jcnb7ikeCvdaYtPaPwCXTj2L8ILzwC7TURQ9UILd+NeTEPqU6WweYDJxUfrIO/2U8Y ujJ1b+9i8QAFsvd7mV6bLzWUdsxpKCub8b9eSZeIPCdX04N2sM1NDGkSjSS43Zm5TNpz pabZATzRXEwtZgs7Zh3E1W3afEh0gWG73OiOrnu+24KKq83M6zALdcK2yTjQ5CpkK5vF xGehWRZlUSptwZo8h2lzY44nN7/1KuE0IFh3E+Y9PvzMorNjE+3bETGHNZKbWc0MMXFS RztUj5fslDh2xsacvshwMZMO5aBccyPlzwwejSQUxxsLOXZ3vRE55fAGcwI9Mm4OJAIk EEUQ== X-Gm-Message-State: APjAAAXFLIEmxw3iXYERHVxZtmzLUIUKy5PjtqHhnjRVtamodJzkg00j yNm8QCI1XZqbzXaCrWFKbCr7i2EN X-Google-Smtp-Source: APXvYqwEphIt+i/vp3Fv34jwENhRoHFuwAYLAt6U4W/7CrHpptJJkz5ljgJLP100XNGqYhgy+DhUCA== X-Received: by 2002:adf:ed41:: with SMTP id u1mr9181806wro.162.1562432561886; Sat, 06 Jul 2019 10:02:41 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id u186sm5531662wmu.26.2019.07.06.10.02.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Jul 2019 10:02:41 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Jul 2019 18:59:22 +0200 Message-Id: <20190706165922.30457-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] matroskadec: Fix overflow introduced in a569a7b3 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This commit fixes an overflow introduced in a569a7b3 that affected EBML elements that the Matroska demuxer doesn't want to parse like CRC-32 elements. The return value of avio_skip (the new position on success or an AVERROR on failure) has been assigned to an integer which meant that new positions in the range of 2GB to 4GB-1 etc. were considered errors. Fixes ticket #8001. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index bc73bfed11..4d7076fa26 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1259,12 +1259,13 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, return 1; default: if (length) { + int64_t res2; if (ffio_limit(pb, length) != length) { // ffio_limit emits its own error message, // so we don't have to. return AVERROR(EIO); } - if ((res = avio_skip(pb, length - 1)) >= 0) { + if ((res2 = avio_skip(pb, length - 1)) >= 0) { // avio_skip might take us past EOF. We check for this // by skipping only length - 1 bytes, reading a byte and // checking the error flags. This is done in order to check @@ -1272,7 +1273,8 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, // no filesize (that ffio_limit relies on) is available. avio_r8(pb); res = NEEDS_CHECKING; - } + } else + res = res2; } else res = 0; }