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

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit ae67acf484fd046efc4c8861c008ca3c3ab5f698
Author: Dominique Leuenberger <[email protected]>
AuthorDate: Wed Sep 2 14:55:49 2026 +0200

    loader_ico: fix 32-bit byteswap macro usage on 16-bit struct fields
    
    Modern toolchains (like GCC 15/16) tracking strict value propagation
    throw an overflow error when compiled with `-Werror` on Big Endian
    architectures like s390x.
    
    The BMP header specification defines `planes` and `bpp` as 16-bit
    unsigned integers (`uint16_t`). The `loader_ico.c` file
    was wrapping them in `SWAP_LE_32_INPLACE`, forcing a 32-bit
    manipulation
    that narrows back to 16 bits. On Little Endian hosts, this is optimized
    out
    as a no-op, but on Big Endian architectures, it actively swaps bytes,
    resulting in an explicit narrowing overflow and potential data
    corruption.
    
    Fix this by replacing `SWAP_LE_32_INPLACE` with the correct 16-bit
    counterpart `SWAP_LE_16_INPLACE` for the `planes` and `bpp` fields.
---
 src/modules/loaders/loader_ico.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c
index 6d50366..0fa2051 100644
--- a/src/modules/loaders/loader_ico.c
+++ b/src/modules/loaders/loader_ico.c
@@ -156,8 +156,8 @@ ico_read_icon(ico_t *ico, int ino)
     SWAP_LE_32_INPLACE(ie->bih.width);
     SWAP_LE_32_INPLACE(ie->bih.height);
 
-    SWAP_LE_32_INPLACE(ie->bih.planes);
-    SWAP_LE_32_INPLACE(ie->bih.bpp);
+    SWAP_LE_16_INPLACE(ie->bih.planes);
+    SWAP_LE_16_INPLACE(ie->bih.bpp);
 
     SWAP_LE_32_INPLACE(ie->bih.compression);
     SWAP_LE_32_INPLACE(ie->bih.size);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to