This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 87f6fa9d41 avcodec/bmp: fix misaligned read in 16-bit decoding
87f6fa9d41 is described below

commit 87f6fa9d41e4a31faeabd355a9c2365c6bb9465f
Author:     Haochen Chen <[email protected]>
AuthorDate: Thu Jul 30 22:54:16 2026 +0000
Commit:     michaelni <[email protected]>
CommitDate: Thu Aug 13 20:46:10 2026 +0000

    avcodec/bmp: fix misaligned read in 16-bit decoding
    
    Fixes a misaligned read in bmp_decode_frame when decoding 16-bit BMPs.
    The code was casting a potentially unaligned uint8_t pointer to uint16_t* 
and dereferencing it.
    This triggers a UBSAN trap (SIGILL / UD1) on environments configured to 
trap on undefined behavior.
    Replaced with AV_RL16 to perform safe unaligned reads.
    
    Signed-off-by: Haochen Chen <[email protected]>
---
 libavcodec/bmp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index db5d704057..c7614f6f7e 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -27,6 +27,7 @@
 #include "codec_internal.h"
 #include "decode.h"
 #include "msrledec.h"
+#include "libavutil/intreadwrite.h"
 
 static int bmp_decode_frame(AVCodecContext *avctx, AVFrame *p,
                             int *got_frame, AVPacket *avpkt)
@@ -326,11 +327,13 @@ static int bmp_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
             break;
         case 16:
             for (i = 0; i < avctx->height; i++) {
-                const uint16_t *src = (const uint16_t *) buf;
+                const uint8_t *src  = buf;
                 uint16_t *dst       = (uint16_t *) ptr;
 
-                for (j = 0; j < avctx->width; j++)
-                    *dst++ = av_le2ne16(*src++);
+                for (j = 0; j < avctx->width; j++) {
+                    *dst++ = AV_RL16(src);
+                    src += 2;
+                }
 
                 buf += n;
                 ptr += linesize;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to