Commit 66ebd818ed for ffmpeg
commit 66ebd818ed11750327536fcf7ac9abd73b16ce17
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Fri Nov 27 10:33:02 2026 -0800
avcodec/ac3_parser: zero the sync window padding
The header parser can read past the sync window. Initializing the
union through its uint64_t member left the remaining bytes
uninitialized with MinGW GCC. Use a zero-initialized byte array.
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 232c96d517..c5da503242 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -444,20 +444,19 @@ int av_ac3_parse_header(const uint8_t *buf, size_t size,
static int ac3_sync(uint64_t state, int *need_next_header, int *new_frame_start)
{
int err;
- union {
- uint64_t u64;
- uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE];
- } tmp = { av_be2ne64(state) };
+ /* The header parser also reads past the sync window. */
+ uint8_t tmp[8 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
AC3HeaderInfo hdr;
GetBitContext gbc;
- if (tmp.u8[1] == 0x77 && tmp.u8[2] == 0x0b) {
- FFSWAP(uint8_t, tmp.u8[1], tmp.u8[2]);
- FFSWAP(uint8_t, tmp.u8[3], tmp.u8[4]);
- FFSWAP(uint8_t, tmp.u8[5], tmp.u8[6]);
+ AV_WB64(tmp, state);
+ if (tmp[1] == 0x77 && tmp[2] == 0x0b) {
+ FFSWAP(uint8_t, tmp[1], tmp[2]);
+ FFSWAP(uint8_t, tmp[3], tmp[4]);
+ FFSWAP(uint8_t, tmp[5], tmp[6]);
}
- init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
+ init_get_bits(&gbc, tmp + 8 - AC3_HEADER_SIZE, 54);
err = ff_ac3_parse_header(&gbc, &hdr);
if(err < 0)