Hi Omar,
Some of this was done just after v1.12.0:
https://git.enlightenment.org/old/legacy-imlib2/commit/74dae151cd02c95d35fbd9ca8a20f21ec1c9cdec
Using fstat() would be the proper thing to do but in case of failure fd
needs to be closed.
/Kim
On 2023-09-04 17:44, Omar Polo wrote:
Spotted thanks to a warning of the compiler. While here convert it to
fstat after open, and range check the value we're about to mmap.
Thanks,
Omar Polo
Index: src/bin/imlib2_load.c
--- src/bin/imlib2_load.c.orig
+++ src/bin/imlib2_load.c
@@ -91,16 +91,19 @@ image_load_mem(const char *file, int *perr)
else
ext = file;
- err = stat(file, &st);
- if (err)
- goto bail;
-
im = NULL;
fd = -1;
fdata = MAP_FAILED;
fd = open(file, O_RDONLY);
if (fd < 0)
+ goto bail;
+
+ err = fstat(fd, &st);
+ if (err)
+ goto bail;
+
+ if (st.st_size > SIZE_MAX)
goto bail;
fdata = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel