🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #4705

Bug#1154148: exiv2: reading QuickTime/MP4 metadata allocates a buffer the size of the whole video (fixed upstream in 0.28.9)

#4705
From: Emmanuel Revah
Date: Mon, 16 Nov 2026 11:10
134 lines
6705 bytes
--=_de36d285d401f0fd3c5351836097ff8e
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII;
 format=flowed

Source: exiv2
Version: 0.28.5+dfsg-1
Severity: important
Tags: patch fixed-upstream trixie

Dear Maintainer,

In trixie, reading the metadata of a QuickTime/MP4 video with libexiv2
allocates (and zero-fills) a buffer as large as the video itself. A 
phone
video of 8.46 GB makes any program that reads its metadata take ~8 GB of 
RAM
for a few seconds, which on a 16 GB desktop means heavy swapping and a
frozen application.

How I hit it: Gwenview, with a photo folder sorted by date. To sort,
Gwenview reads the date of every file through libexiv2, videos included,
on its GUI thread. Opening any photo in a camera folder that contains 
one
large video made Gwenview grow to 8.2-8.5 GB within seconds, freeze, and
end up killed via KWin's "not responding" dialog.


Cause
-----

src/quicktimevideo.cpp, QuickTimeVideo::decodeBlock(): after reading a 
box
header, the 5-byte tag buffer is resized to the full box size

     const auto newsize = static_cast<size_t>(size - hdrsize);
     if (newsize > buf.size()) {
       buf.resize(newsize);
     }
     tagDecoder(buf, newsize, recursion_depth + 1);

before tagDecoder() looks at the tag. For "mdat" (the media data, i.e.
almost the whole file) tagDecoder() only calls discard(size), a seek. 
The
buffer is never used beyond its first 4 bytes, but resize() has already
allocated and zero-filled it.

Upstream removed the resize in 0.28.9 (and main):
   https://github.com/Exiv2/exiv2/commit/40be751eda  (0.28.x, "Remove 
unnecessary resize")
   https://github.com/Exiv2/exiv2/commit/1a1f0ab960  (main)

forky and sid have 0.28.9+dfsg-1 and are fixed. Only trixie is affected.

The memory is bounded by the file size (decodeBlock() enforces that a 
box
fits in the remaining file), so this is not a crafted-file issue; it 
hits
ordinary large videos.


Reproduce (plain trixie)
------------------------

     exiv2 -q -pa some-large-video.mp4

and look at the maximum RSS (e.g. /usr/bin/time -v, or getrusage).

Measured here, with the exiv2 0.28.5+dfsg-1 command line tool:

- 8.46 GB .mp4, stock libexiv2-28 0.28.5+dfsg-1: max RSS 6.6 GB, 4.1 s
   (the rest was pushed to swap)
- same file, libexiv2-28 rebuilt with the attached patch: max RSS 11 MB, 
0.1 s
- 0.68 GB .mp4, stock: 657 MB; patched: 11 MB

In Gwenview (4:25.04.3-1), same folder, the A/B gave 7.3 GB peak + 676 
MB
swap with the stock library, 120 MB with the patched one.


Patch
-----

The attached patch is the upstream commit, unchanged apart from the 
DEP-3
header; it applies to 0.28.5+dfsg-1 with a 1-line offset. In 0.28.5,
tagDecoder() only ever reads 4 bytes into this buffer, so removing the
resize is safe on its own. I rebuilt the Debian package with it
(0.28.5+dfsg-1 + this patch only): the package test suite passes (100%,
6/6 ctest groups).


Request
-------

Please consider the attached patch for a trixie stable update.


-- System Information:
Debian Release: 13 (trixie)
Kernel: Linux 6.12.116+deb13-amd64
Versions: libexiv2-28 0.28.5+dfsg-1, gwenview 4:25.04.3-1



-- 
Emmanuel Revah
--=_de36d285d401f0fd3c5351836097ff8e
Content-Transfer-Encoding: base64
Content-Type: text/x-diff; charset=us-ascii;
 name=exiv2_40be751eda_quicktime-remove-unnecessary-resize.patch
Content-Disposition: attachment;
 filename=exiv2_40be751eda_quicktime-remove-unnecessary-resize.patch;
 size=966

RGVzY3JpcHRpb246IFF1aWNrVGltZVZpZGVvOiBkb24ndCBhbGxvY2F0ZSBhIGJ1ZmZlciB0aGUg
c2l6ZSBvZiBldmVyeSBib3gKIGRlY29kZUJsb2NrKCkgcmVzaXplZCBpdHMgdGFnIGJ1ZmZlciB0
byB0aGUgZnVsbCBib3ggc2l6ZSBiZWZvcmUgdGFnRGVjb2RlcigpCiBjaGVja2VkIHRoZSBpZ25v
cmUgbGlzdCwgc28gdGhlICdtZGF0JyBib3ggKOKJiCB0aGUgd2hv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: <O02L0-ceSc-13@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.nntp4.net!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.nntp4.net!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Emmanuel Revah <bugreport@manurevah.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1154148: exiv2: reading QuickTime/MP4 metadata allocates a buffer the size of the whole video (fixed upstream in 0.28.9)
Date: Mon, 16 Nov 2026 12:10:02 +0100
Message-ID: <O02L0-ceSc-13@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Mon Nov 16 11:05:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.451
Reply-To: Emmanuel Revah <bugreport@manurevah.com>, 1154148@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: pkg-kde-extras@lists.alioth.debian.org
X-Debian-Pr-Message: report 1154148
X-Debian-Pr-Package: src:exiv2
X-Debian-Pr-Keywords: fixed-upstream patch trixie
X-Debian-Pr-Source: exiv2
MIME-Version: 1.0
User-Agent: Roundcube Webmail
X-Sender: bugreport@manurevah.com
Content-Type: multipart/mixed;
 boundary="=_de36d285d401f0fd3c5351836097ff8e"
X-Greylist: delayed 570 seconds by postgrey-1.37 at buxtehude; Mon, 16 Nov 2026 11:02:20 UTC
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2002939
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 134
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Mon, 16 Nov 2026 11:53:14 +0100
X-Original-Message-ID: <179482510548.38912.18072731586983468285@manurevah.com>