Commit c307a77f for libheif
commit c307a77f43431438c9553798d4031a9b3eb8d07d
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu Oct 15 20:41:45 2026 +0200
heif-enc: reject WebVMT minutes and seconds above 59
The WebVMT timestamp algorithm returns an error for minutes or seconds
greater than 59. The pattern accepted any two digits, so 00:60.000 was
read as 60 seconds and 75:00.000 as 75 minutes.
diff --git a/examples/vmt.cc b/examples/vmt.cc
index 2249c480..534ac322 100644
--- a/examples/vmt.cc
+++ b/examples/vmt.cc
@@ -179,8 +179,14 @@ static uint32_t parse_vmt_timestamp(const std::string& vmt_time)
return 0; // negative time not supported
}
+ int minutes = std::stoi(mm);
+ int seconds = std::stoi(ss);
uint32_t ms = std::stoi(fs); // the pattern guarantees exactly three digits
+ if (minutes > 59 || seconds > 59) {
+ return BAD_VMT_TIMESTAMP;
+ }
+
// The timestamp is stored in a 32 bit millisecond counter. Reject hour values that cannot fit
// (and that would overflow std::stoi) before doing any arithmetic.
if (hh.length() > 9) {
@@ -188,8 +194,8 @@ static uint32_t parse_vmt_timestamp(const std::string& vmt_time)
}
uint64_t ts = ((hh != "" ? std::stoull(hh) : 0) * 3600 * 1000 +
- std::stoi(mm) * 60 * 1000 +
- std::stoi(ss) * 1000 +
+ minutes * 60 * 1000 +
+ seconds * 1000 +
ms);
if (ts >= BAD_VMT_TIMESTAMP) {