Commit 1838782c51 for ffmpeg
commit 1838782c512782d8903372822c7d74d70f0b2ad4
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Tue Nov 3 20:42:25 2026 +0100
avutil/hash: terminate the hex string when size is 1
Found during triage of the security report qG4gdnzp4yAQ
Unterminated string Replicated through API with ASAN
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libavutil/hash.c b/libavutil/hash.c
index fbc24194de..10f055aa40 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -228,7 +228,7 @@ void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
unsigned rsize = av_hash_get_size(ctx), i;
av_hash_final(ctx, buf);
- for (i = 0; i < FFMIN(rsize, size / 2); i++)
+ for (i = 0; i < FFMIN(rsize, size - size / 2); i++)
snprintf(dst + i * 2, size - i * 2, "%02x", buf[i]);
}