Commit a1bd814fcc for ffmpeg
commit a1bd814fcca78263fb009865e44c8535b44a140a
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Tue Nov 17 08:44:17 2026 -0600
avformat/hevc: fail on a truncated hvcC record
When a NAL unit length ran past the end of the record, the writer
stopped without writing anything and still returned success.
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index a98422103e..877900f353 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -1346,8 +1346,10 @@ static int write_configuration_record(void *logctx, AVIOContext *pb, const uint8
for (int j = 0; j < num_nalus; j++) {
int len = get_bits(&gbc, 16);
- if (len > (get_bits_left(&gbc) / 8))
+ if (len > (get_bits_left(&gbc) / 8)) {
+ ret = AVERROR_INVALIDDATA;
goto end;
+ }
ret = hvcc_parse_nal_unit(data + get_bits_count(&gbc) / 8,
len, type, &hvcc, flags);