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 36c1daef60834d10418bbe08c13046ba3c38b5bb
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Tue Jun 20 09:38:51 2023 +0200

    TGA loader: Fix TGA v2.0 signature check
    
    With normal struct padding the footer pointer was not calculated correctly.
    Now also checking the last two bytes ('.', '\0').
---
 src/modules/loaders/loader_tga.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index 083f455..76f6ac6 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -32,7 +32,7 @@ static void         tgaflip(uint32_t * in, int w, int h, int fliph, int flipv);
 #define TGA_DESC_HORIZONTAL 0x10
 #define TGA_DESC_VERTICAL   0x20
 
-#define TGA_SIGNATURE "TRUEVISION-XFILE"
+static const char   tga_signature[18] = "TRUEVISION-XFILE.";
 
 typedef struct {
    unsigned char       idLength;
@@ -49,12 +49,10 @@ typedef struct {
    unsigned char       descriptor;
 } tga_header;
 
-typedef struct __PACKED__ {
-   unsigned int        extensionAreaOffset;
-   unsigned int        developerDirectoryOffset;
-   char                signature[16];
-   char                dot;
-   char                null;
+typedef struct {
+   unsigned char       extensionAreaOffset[4];
+   unsigned char       developerDirectoryOffset[4];
+   char                signature[18];
 } tga_footer;
 
 /* Load up a TGA file
@@ -95,10 +93,10 @@ _load(ImlibImage * im, int load_data)
    if (im->fi->fsize > (int)(sizeof(tga_footer)))
      {
         footer =
-           PCAST(const tga_footer *, fptr + im->fi->fsize - sizeof(tga_footer));
+           (const tga_footer *)(fptr + im->fi->fsize - sizeof(tga_footer));
 
         /* check the footer to see if we have a v2.0 TGA file */
-        footer_present = memcmp(footer->signature, TGA_SIGNATURE,
+        footer_present = memcmp(footer->signature, tga_signature,
                                 sizeof(footer->signature)) == 0;
      }
    else

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

Reply via email to