Thread View: linux.debian.bugs.dist
1 messages
1 total messages
Started by Emmanuel Revah
Mon, 16 Nov 2026 11:10
Bug#1154148: exiv2: reading QuickTime/MP4 metadata allocates a buffer the size of the whole video (fixed upstream in 0.28.9)
Author: Emmanuel Revah
Date: Mon, 16 Nov 2026 11:10
Date: Mon, 16 Nov 2026 11:10
134 lines
6705 bytes
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
cmUgbGlzdCwgc28gdGhlICdtZGF0JyBib3ggKOKJiCB0aGUgd2hvbGUgdmlkZW8p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full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads