[E-devel] small tga loader fix

noospot <[email protected]>
Newsgroups gmane.comp.window-managers.enlightenment.devel
Message-ID <[email protected]>
hi,

I stumbled upon a tiny tga image  imlib2 couldn't load while other
softs could .

I did check the imlib2-1.7.1/src/modules/loaders/loader_tga.c    code
I found sizeof(tga_footer) is used  -line191- -line201-  earlier than
to check a footer presence -line202-

with patch below the image loads correctly.

image is maybe attached  to this mail       sample_rle_3c_cmap.tga
or its maybe there:  https://filebin.net/enqoaglfjl649ou5
or its maybe there: https://noospot.dynv6.net/sample_rle_3c_cmap.tga

imlib2 version 1.7.1
debian buster package    imlib2_1.7.1-2

thanks



--- imlib2-1.7.1-tgapatch/src/modules/loaders/loader_tga.c
2021-07-05 14:53:54.856994118 +0100 +++
imlib2-1.7.1/src/modules/loaders/loader_tga.c	2020-12-09
16:45:59.000000000 +0000 @@ -188,7 +188,7 @@ if (fstat(fd, &ss) < 0)
       goto quit;
 
-   if (ss.st_size < (long)(sizeof(tga_header) ) ||
+   if (ss.st_size < (long)(sizeof(tga_header) + sizeof(tga_footer)) ||
        (uintmax_t) ss.st_size > SIZE_MAX)
       goto quit;
 
@@ -198,17 +198,11 @@
 
    filedata = seg;
    header = (tga_header *) filedata;
-   
-  if (ss.st_size >(long)(sizeof(tga_footer))  ) {
    footer = (tga_footer *) ((char *)filedata + ss.st_size -
sizeof(tga_footer)); 
    /* check the footer to see if we have a v2.0 TGA file */
    footer_present =
       memcmp(footer->signature, TGA_SIGNATURE,
sizeof(footer->signature)) == 0;
-  } else{
-      footer_present =0;  
-  }
-
 
    if ((size_t)ss.st_size < sizeof(tga_header) + header->idLength +
        (footer_present ? sizeof(tga_footer) : 0))

_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
sample_rle_3c_cmap.tga (image/x-tga, 42 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.