Commit Graph

719 Commits

Author SHA1 Message Date
Kim Woelders 51a48ecfe9 BMP loader: Fix infinite loop with invalid bmp images (T6749)
https://phab.enlightenment.org/T6749
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773968
2018-03-07 20:26:21 +01:00
Kim Woelders 5a7644a0c0 XPM loader: Fix potential use of uninitialized value (T6746)
https://phab.enlightenment.org/T6746
https://bugs.debian.org/868151
2018-03-07 19:45:39 +01:00
Kim Woelders 8038d9c618 Fix build without HAVE_X11_SHM_FD (T6752) 2018-03-07 19:44:05 +01:00
Kim Woelders 63103ae48c Expose XImage cache control functions 2018-02-17 13:23:13 +01:00
Kim Woelders 5cf3e34ff1 Add imlib_get_cache_used()
And some cosmetics.
2018-02-17 11:56:42 +01:00
Kim Woelders 327f8c0ce4 Refactor the XImage cache
Simpler, faster.
2018-02-10 10:53:42 +01:00
Kim Woelders 6a2e839313 Add IMLIB2_XIMAGE_CACHE_COUNT to enable testing the ximage cache 2018-02-10 10:30:16 +01:00
Kim Woelders 096316b476 Introduce IMLIB2_SHM_OPT to enable overriding/testing SHM modes 2018-02-10 10:30:16 +01:00
Kim Woelders c975dab9cd Fix potential OOB memory access if border sizes exceed image dimensions 2018-02-09 18:45:47 +01:00
Kim Woelders 96dde44a14 Fix potential OOB memory access if border elements are negative 2018-02-09 18:45:47 +01:00
Kim Woelders 65fb0c8249 Strip trailing whitespace, cosmetics 2018-02-09 18:45:32 +01:00
Kim Woelders 0f829f474b Indent 2018-02-08 15:37:56 +01:00
Alexander Volkov ca17031280 Add support for MIT-SHM FD-passing
Summary:
This is more secure way of using shared memory because
it's visible only to the X server and the application.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5788
2018-02-08 15:34:53 +01:00
Alexander Volkov 56ca24fc9f introduce __imlib_ShmDestroyXImage() instead of __imlib_ShmDetach()
Summary:
It enhances the code, because __imlib_ShmDestroyXImage() is symmetrical
to __imlib_ShmGetXImage(), while __imlib_ShmDetach() looks unrelated.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5787
2018-02-08 15:34:53 +01:00
Alexander Volkov 6f62c70bac put a check for shared memory inside __imlib_ShmGetXImage()
Summary:
This check actually refers to the internal implementation
and should not be done outside this function.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D5783
2018-02-08 15:34:53 +01:00
Kim Woelders 8232c9213b imlib_create_scaled_image_from_drawable(): Drop shape handling if unshaped 2017-12-23 19:35:15 +01:00
Kim Woelders 257a72fabe imlib_create_scaled_image_from_drawable(): speed up 1:1 case 2017-12-23 19:32:52 +01:00
Kim Woelders 2d1ec6979b imlib2_grab: Always use imlib_create_scaled_image_from_drawable() to grab image
Apparently, when using XShmGetImage to get an XImage for a (non-root?)
window, the image no longer includes subwindows (like when using
IncludeInferiors in GC).
When using XGetImage the XImage still includes subwindows.

imlib_create_scaled_image_from_drawable() (as opposed to
imlib_create_image_from_drawable() ) is implemented in such a way
that the drawable to be grabbed is always copied to a pixmap first.

This way we always get the "IncludeInferiors" type grab we most likely
want here.
2017-12-23 19:00:00 +01:00
Kim Woelders 854fca3395 Remove redundant CAST_IMAGE() 2017-12-17 11:06:43 +01:00
Kim Woelders a3e8395435 Introduce __imlib_LoadImageData() 2017-12-17 11:06:38 +01:00
Kim Woelders 1c413c1f35 Make some more functions static. 2017-12-15 17:36:52 +01:00
Kim Woelders 812a691b16 XPM loader: Fix incorrect image invalidation.
Introduced in d5ebec2948.
2017-05-01 21:58:07 +02:00
Tobias Stoeckmann fe7ae79084 Prevent OOB read with large file support on 32 bit
If imlib2 is compiled with large file support on 32 bit systems, which
is not the default, the TGA loader is vulnerable to an out of boundary
read due to insufficient off_t/size_t validations.

If large file support is enabled, off_t is 64 bit, while size_t is the
regular 32 bit on 32 bit architectures. Casting directly leads to issues
with files which are larger than 4 GB.

As it's unlikely to encounter such files, they will be simply ignored
on such systems.

64 bit systems are not affected.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-03-25 07:21:49 +01:00
Tobias Stoeckmann d5ebec2948 Properly release resources on error path
The code did not properly release resources in some error paths,
leading to memory leaks or possible double free issues.

If an image could not be loaded, some code paths check if width is 0
to determine if an error occurred. Therefore, always set width to 0
in such cases.
2017-03-12 09:52:02 +01:00
Tobias Stoeckmann 993911b6e5 Avoid out of boundary operations while parsing xpm
It is possible to trigger out of boundary read and write accesses while
parsing XPM files.

1. If the color definition is shorter than the specified cpp, i.e.
   characters per pixel, an out of boundary write can be triggered.
   The write will modify stack memory and could therefore be used to
   corrupt local variables or return addresses.
2. If the pixel area contains less than the required amount of
   characters per pixel, an out of boundary read can be triggered.
   This affects files with more than one character per pixel.
3. If an out of memory condition occurs, a null pointer dereference can
   be triggered because the variable line is reallocated if not enough
   memory was available. Dereferencing line with an offset would lead
   to yet another out of boundary write, which will lead to a
   segmentation fault on almost every system out there.
2017-02-20 21:03:36 +01:00
Kim Woelders 1f96129e2c Fix missing break.
Found by gcc 7:

grab.c: In function ‘__imlib_GrabXImageToRGBA’:
grab.c:85:14: error: this statement may fall through [-Werror=implicit-fallthrough=]
              for (y = 0; y < h; y++)
              ^~~
grab.c:97:11: note: here
           case 24:
           ^~~~
2017-02-12 20:43:53 +01:00
Kim Woelders f6d902efd9 PNM loader: Fix reading PNM bitmaps.
Attempting to read a PNM bitmap (ASCII format) would cause a lockup due
to infinite loop, and in certain cases write access outside allocated
memory.

Fixes CVE-2016-6348 (out-of-bounds writes ... presumably - CVE text not
disclosed yet).
Found by Neelima Krishnan, Intel Corporation.
2016-09-03 10:53:11 +02:00
Kim Woelders a0259d5181 Fix various potential OOM crashes.
There were several potential OOM crashes in __imlib_ListFilters(),
__imlib_ListLoaders() and __imlib_TrimLoaderList().

The fix of __imlib_TrimLoaderList() is from patch by
Yuriy M. Kaminskiy <yumkam@gmail.com>.
2016-04-16 17:35:08 +02:00
Kim Woelders 5b54980364 Move __imlib_ItemInList() to file.c.
It may not be the ideal location but it's better than image.c
2016-04-16 16:58:15 +02:00
Kim Woelders 31a261ac37 Trivial file function cleanups. 2016-04-15 22:05:22 +02:00
Kim Woelders b49e71ed77 Eliminate pImlibExternalFilter type. 2016-04-15 22:00:01 +02:00
Kim Woelders bdd7630a21 Make a number of functions static. 2016-04-15 21:59:52 +02:00
Yuriy M. Kaminskiy 633a8667b1 Harden API and internals against overly large images
Prevents potential integer overflow -> insufficient allocation -> heap overflow scenarios.
2016-04-13 22:21:58 +02:00
Alexander Smirnov 7836d83951 Fix cross-endianness for masks (1-bit depth images)
Summary:
Imlib generates masks on the client side with the bit order
of the client. Set this bit order for produced XImages.

Reviewers: kwo

Differential Revision: https://phab.enlightenment.org/D3891
2016-04-13 22:10:10 +02:00
Yuriy M. Kaminskiy ecfe46cc4a loader_xpm: remove nonsense/impossible/broken condition
1) ptr is DATA32 *, so (ptr-im->data) is (w * h) at most;
so this condition was broken, it should've been ((ptr-im->data) >= w*h);
2) ... however, ptr != NULL and (context > 1) are only possible together,
and ptr and count are incremented always together too, so
there are no point to check both; leave only less expensive check.
2016-04-12 20:00:56 +02:00
Yuriy M. Kaminskiy 7eba2e4c8a Fix integer overflow resulting in insufficient heap allocation
IMAGE_DIMENSIONS_OK ensures that image width and height are less then
46340, so that maximum number of pixels is ~2**31.

Unfortunately, there are a lot of code that allocates image data with
something like

   malloc(w * h * sizeof(DATA32));

Obviously, on 32-bit machines this results in integer overflow,
insufficient heap allocation, with [massive] out-of-bounds heap
overwrite.
Either X_MAX should be reduced to 32767, or (w)*(h) should be checked to
not exceed ULONG_MAX/sizeof(DATA32).

Security implications:
*) for 32-bit machines: insufficient heap allocation and heap overwrite
in many image loaders, with escalation potential to remote code
execution;
*) for 64-bit machines: it seems, no impact.
2016-04-09 14:54:46 +02:00
Kim Woelders c94d83ccab Fix potential divide-by-zero in imlib_image_draw_ellipse().
Attempting to draw a 2x1 ellipse with e.g. imlib_image_draw_ellipse(x, y, 2, 1)
causes a divide-by-zero.
It seems happy enough to draw 1x1, 1x2 and 2x2, but not 2x1.

Patch by Simon Lees.

https://bugs.debian.org/639414
2016-04-07 20:24:32 +02:00
Kim Woelders a8ca99a2a4 GIF loader: Indent.
And remove now unused label "finish".
2016-04-07 20:20:47 +02:00
Kim Woelders 1efd421614 GIF loader: Reduce progress checks from per-pixel to per-row.
Patch by Yuriy M. Kaminskiy.
2016-04-07 20:20:47 +02:00
Kim Woelders bfa12b68fe GIF loader: Remove check made redundant by previous commit.
Patch by Yuriy M. Kaminskiy.
2016-04-07 20:20:47 +02:00
Kim Woelders 37a9680166 GIF loader: Fix out-of-bound reads from colormap.
Bug-Debian: http://bugs.debian.org/785369
Note: removes all special-casing from the inner loop, optimize for common case.
Author: Yuriy M. Kaminskiy <yumkam+debian@gmail.com>
Reported-By: Jakub Wilk <jwilk@debian.org>

Thanks to Bernhard U:belacker <bernhardu@vr-web.de> for analysis.
2016-04-07 20:20:47 +02:00
Kim Woelders 5b5544ab77 Revert "gif: fix oob reads w/bad colormaps"
This reverts commit 16de244bd0.

Will push alternative solution.
2016-04-07 20:20:47 +02:00
Kim Woelders ce94edca1c Fix off-by-one OOB read in __imlib_MergeUpdate().
Patch by Yuriy M. Kaminskiy.

https://bugs.debian.org/819818
2016-04-06 02:36:23 +02:00
Bernhard Übelacker 16de244bd0 gif: fix oob reads w/bad colormaps
Verify the color map is inbounds before indexing with it.

https://bugs.debian.org/785369
2016-04-02 16:25:35 -04:00
Kim Woelders c0747f9fc9 Fix some "variable might be clobbered" warnings. 2016-03-21 09:16:44 +01:00
Kim Woelders 078fadde02 Fix some "variable set but not used" warnings. 2016-03-21 09:16:35 +01:00
Kim Woelders 94a357482b Fix "assuming signed overflow does not occur" warning. 2016-03-21 09:16:24 +01:00
Quentin Rameau 81fefc5785 Fix zlib loader filename check
Do not impose an arbitrary small buffer size limit on filenames when
checking and trimming gz extension.
2016-02-09 16:46:46 +01:00
Quentin Rameau bbde5efdc0 Fix bz2 loader filename check
Do not impose an arbitrary small buffer size limit on filenames when
checking and trimming bz2 extension.
2016-02-09 16:46:43 +01:00
Kim Woelders 93e6176764 Indent. 2016-02-07 08:08:00 +01:00
FRIGN 5cabf38155 Add a Farbfeld loader
(http://tools.suckless.org/farbfeld)
2016-02-07 08:01:40 +01:00
Kim Woelders bc35a1f7aa Remove redundant config.h. 2015-11-01 15:17:34 +01:00
Chloe Kudryavtsev 521573be21 add time.h include to common.h for time_t 2015-11-01 15:04:53 +01:00
Kim Woelders ec1b4319b8 Indent the remaining unindented files. 2014-12-20 17:02:11 +01:00
Kim Woelders e20587d7a7 Enable visibility hiding by default. 2014-12-20 10:35:28 +01:00
Kim Woelders 98cec42013 Remove __hidden.
Going to to set -fvisibility=hidden (as default) shortly...
2014-12-20 10:35:28 +01:00
Kim Woelders cd902be360 Don't include Imlib2.h indirectly via image.h.
Also avoid using EAPI internally (requiring Imlib2.h).
2014-12-20 10:35:28 +01:00
Kim Woelders 3a121573f3 Indent. 2014-12-20 10:35:28 +01:00
Kim Woelders 54594ccd8d Change a number of internal function names.
Consistenly use the __-prefix on internal imlib_... functions.
2014-12-16 20:35:37 +01:00
Kim Woelders a4dd5bcdc2 Autofoo macro cleanups (ac_->ec_).
- Changes names AC_/ac_ to EC_/ec_ to stay out of autoconf namespace.
2014-12-16 20:30:48 +01:00
Kim Woelders 4350b08dfe BMP loader: Simplify pixel fetch.
No need to go though elaborate API call (imlib_image_query_pixel()).
2014-12-16 20:04:58 +01:00
Kim Woelders 7b7d1aaf7b JPEG loader: Fix load() return code when only reading header.
Also simplify exit/error handling.
2014-12-16 20:03:28 +01:00
Kim Woelders 534f6c42a3 Revert "loader_gif(): Abort gif parsing if DGifGetLine() fails"
This reverts commit 2c6a3af9b6.

The fix breaks loading of certain images that at least apparently were
loaded just fine before.
2014-12-16 19:56:00 +01:00
Kim Woelders 55ddd412c3 Revert "__imlib_LoadImage(): Additionally check loader_ret to detect loader failures"
This reverts commit a104e317ce.

Breaks image loading in certain situations.

It seems that some loaders may return 0 even when load() "succeeds".

This appears to happen with the jpeg loader when not loading data
immediately (but only reading the header).
In this case jpeg_finish_decompress() exits via _JPEGFatalErrorHandler()
-> longjmp() causing the return code to be 0.

The fix reverted here is probably basically correct, but it will have to
wait until the loaders are fixed to behave properly.
2014-12-14 20:27:39 +01:00
Fabian Keil 0c34e1bfe2 load_gif: Make sure rows isn't used partly unitialized
Prevents:

==22831== Conditional jump or move depends on uninitialised value(s)
==22831==    at 0x634F040: load (loader_gif.c:181)
==22831==    by 0x1F7D7B3: __imlib_LoadImage (image.c:1041)
==22831==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==22831==    by 0x40F47B: feh_load_image (imlib.c:252)
==22831==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==22831==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==22831==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==22831==    by 0x418F13: main (main.c:78)
==22831==
==22831== Use of uninitialised value of size 8
==22831==    at 0x634F0F4: load (loader_gif.c:190)
==22831==    by 0x1F7D7B3: __imlib_LoadImage (image.c:1041)
==22831==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==22831==    by 0x40F47B: feh_load_image (imlib.c:252)
==22831==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==22831==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==22831==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==22831==    by 0x418F13: main (main.c:78)
==22831==
==22831== Use of uninitialised value of size 8
==22831==    at 0x634F122: load (loader_gif.c:191)
==22831==    by 0x1F7D7B3: __imlib_LoadImage (image.c:1041)
==22831==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==22831==    by 0x40F47B: feh_load_image (imlib.c:252)
==22831==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==22831==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==22831==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==22831==    by 0x418F13: main (main.c:78)
==22831==
==22831== Use of uninitialised value of size 8
==22831==    at 0x634F151: load (loader_gif.c:192)
==22831==    by 0x1F7D7B3: __imlib_LoadImage (image.c:1041)
==22831==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==22831==    by 0x40F47B: feh_load_image (imlib.c:252)
==22831==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==22831==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==22831==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==22831==    by 0x418F13: main (main.c:78)
==22831==

when opening id:000001,orig:smaller-animated.gif with feh.
2014-12-06 13:58:35 +09:00
Fabian Keil 60779351df imlib_save_image_with_error_return(): Check loader return code to prevent use of unitialized memor 2014-12-06 13:57:14 +09:00
Fabian Keil 6ef51ec4cd loader_tga.c: Properly signal if decoding RLE compressed data failed
Otherwise uninitilized memory could be used later on.

I don't have a test file for this commit.
2014-12-06 13:57:14 +09:00
Fabian Keil 2fdef015ff loader_tga.c: Properly signal if decoding uncompressed BGRA data failed
Required to reject id:000134,src:000105,op:havoc,rep:32.
2014-12-06 13:57:14 +09:00
Fabian Keil edaf7b669c imlib_save_image(): Check loader return code for errors
Prevents tons of:
==10646== Conditional jump or move depends on uninitialised value(s)
==10646==    at 0x4F7D30C: png_write_find_filter (pngwutil.c:2578)
==10646==    by 0x4F7568F: png_write_row (pngwrite.c:827)
==10646==    by 0x4F751B0: png_write_rows (pngwrite.c:587)
==10646==    by 0x4D40C7D: save (loader_png.c:373)
==10646==    by 0x1297084: __imlib_SaveImage (image.c:1282)
==10646==    by 0x124252B: imlib_save_image (api.c:4615)
==10646==    by 0x401990: main (imlib2_conv.c:74)
when trying to convert id:000134,src:000105,op:havoc,rep:32.
2014-12-06 13:57:14 +09:00
Fabian Keil a2cb5b9c9b loader_tga: Abort file loading if the file obviously isn't large enough
Prevents an integer overflow later on that resulted in a datasize of
18446744073709551575 for id:000131,src:000104,op:havoc,rep:32,+cov
whose actual size is 48 byte.
2014-12-06 13:57:14 +09:00
Fabian Keil a104e317ce __imlib_LoadImage(): Additionally check loader_ret to detect loader failures
Fixes:

==14822== Conditional jump or move depends on uninitialised value(s)
==14822==    at 0x4E08376: load (loader_tiff.c:285)
==14822==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==14822==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==14822==    by 0x40F47B: feh_load_image (imlib.c:252)
==14822==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==14822==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==14822==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==14822==    by 0x418F13: main (main.c:78)
==14822==
==14822== Conditional jump or move depends on uninitialised value(s)
==14822==    at 0x4E083BC: load (loader_tiff.c:285)
==14822==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==14822==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==14822==    by 0x40F47B: feh_load_image (imlib.c:252)
==14822==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==14822==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==14822==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==14822==    by 0x418F13: main (main.c:78)
==14822==

when scaling id:000407,src:000226,op:havoc,rep:32 in feh.
2014-12-06 13:57:14 +09:00
Fabian Keil b0a42f8763 load_pnm: Deal with fread() errors consistently
Was supposed to fixes:
==24603== Invalid read of size 1
==24603==    at 0x1FCD748: __imlib_ScaleAARGB (scale.c:990)
==24603==    by 0x1F9BF81: __imlib_RenderImage (rend.c:405)
==24603==    by 0x1F0F82C: imlib_render_image_part_on_drawable_at_size (api.c:1886)
==24603==    by 0x40CD75: gib_imlib_render_image_part_on_drawable_at_size (gib_imlib.c:231)
==24603==    by 0x42C732: winwidget_render_image (winwidget.c:576)
==24603==    by 0x417ACA: feh_event_handle_keypress (keyevents.c:598)
==24603==    by 0x4190DE: feh_main_iteration (main.c:119)
==24603==    by 0x418F45: main (main.c:82)
==24603==  Address 0x4824832 is 3,650 bytes inside a block of size 4,096 free'd
==24603==    at 0x103E498: free (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==24603==    by 0x234157D: fclose (fclose.c:62)
==24603==    by 0x5B3CD7F: load (loader_pnm.c:540)
==24603==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==24603==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==24603==    by 0x40F47B: feh_load_image (imlib.c:252)
==24603==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==24603==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==24603==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==24603==    by 0x418F13: main (main.c:78)
when using feh to scale input/queue/id:000407,src:000226,op:havoc,rep:32
but isn't sufficient by itself.

Still looks correct to me, though.
2014-12-06 13:57:14 +09:00
Fabian Keil 143f2993d7 Make IMAGE_DIMENSIONS_OK() more restrictive
Prevents invalid reads and unreasonably large memory allocations
with input/queue/id:000210,src:000114,op:int32,pos:3,val:be:+32,+cov:

==20321== Invalid read of size 1
==20321==    at 0x1FCDB16: __imlib_ScaleAARGB (scale.c:1043)
==20321==    by 0x1F9BF81: __imlib_RenderImage (rend.c:409)
==20321==    by 0x1F0F82C: imlib_render_image_part_on_drawable_at_size (api.c:1886)
==20321==    by 0x40CD75: gib_imlib_render_image_part_on_drawable_at_size (gib_imlib.c:231)
==20321==    by 0x42C732: winwidget_render_image (winwidget.c:576)
==20321==    by 0x417ACA: feh_event_handle_keypress (keyevents.c:598)
==20321==    by 0x4190DE: feh_main_iteration (main.c:119)
==20321==    by 0x418F45: main (main.c:82)
==20321==  Address 0x3a12e034 is 12 bytes before a block of size 1,965,846,976 alloc'd
==20321==    at 0x103D293: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==20321==    by 0x5B3D1F1: load (loader_pnm.c:149)
==20321==    by 0x1F7D70F: __imlib_LoadImage (image.c:1041)
==20321==    by 0x1F090E4: imlib_load_image_with_error_return (api.c:1299)
==20321==    by 0x40F47B: feh_load_image (imlib.c:252)
==20321==    by 0x42CA0E: winwidget_loadimage (winwidget.c:753)
==20321==    by 0x42C918: winwidget_create_from_file (winwidget.c:126)
==20321==    by 0x421869: init_slideshow_mode (slideshow.c:62)
==20321==    by 0x418F13: main (main.c:78)
2014-12-06 13:57:14 +09:00
Fabian Keil 1f9b0b3272 Fix segfault when opening input/queue/id:000007,src:000000,op:flip1,pos:51 with feh 2014-12-06 13:54:11 +09:00
Fabian Keil 2c6a3af9b6 loader_gif(): Abort gif parsing if DGifGetLine() fails
Prevents multiple conditinal jumps based on and uses
of unitinitialied memory when parsing fuzzed file
id:000067,src:000000,op:havoc,rep:4,+cov.
2014-12-06 13:50:24 +09:00
Fabian Keil 2a53f202fe loader_gif: Don't read uninitilized memory in case of invalid input
Test file id:000037,src:000000,op:flip8,pos:73,+cov.
2014-12-06 13:50:24 +09:00
Fabian Keil 6e5d43617a imlib_conv: Use proper buffer size to prevent invalid write of size one 2014-12-06 13:45:46 +09:00
Fabian Keil c21beaf178 Prevent division-by-zero crashes 2014-12-06 13:45:46 +09:00
Heiko Becker 540df42aab GIF loader: Fix for libgif version 5.1
Summary:
From giflib-5.1.0's NEWS:
"A small change to the API: DGifClose() and EGifClose() now take a
pointer-to-int second argument (like the corresponding openers)
where a diagnostic code will be deposited when they return
GIF_ERROR."

Test Plan:
I've built imlib2 against giflib-4.2.3 and 5.1.0 and opened a few
gif files with feh.

Reviewers: kwo

Reviewed By: kwo

Differential Revision: https://phab.enlightenment.org/D1529
2014-10-13 17:41:25 +02:00
Michał Górny fb29e4bf8d fix -I flags to support building out-of-source
When building out-of-source, the headers are located in subdirectories
in $(top_srcdir) rather than $(top_builddir). Adjust AM_CPPFLAGS
accordingly.

URL: https://bugs.gentoo.org/510522
2014-05-17 09:23:02 +02:00
Mike Frysinger 4f36e69934 do not link with X libs when X is disabled
URL: https://bugs.gentoo.org/517670
2014-07-28 23:01:23 -04:00
Mike Frysinger cfa257c01f fix X_DISPLAY_MISSING redefined warnings when X is disabled
This is set up in config.h by configure, so avoid defining it again.
2014-07-28 22:59:35 -04:00
Mike Frysinger 560a58e617 check return value of fread/write funcs
This fixes warnings with newer compilers/distros that enable warning
flags by default:
loader_zlib.c: In function 'uncompress_file':
loader_zlib.c:33:17: warning: ignoring return value of 'write',
	declared with attribute warn_unused_result [-Wunused-result]
            write(dest, outbuf, bytes);
                 ^
2014-01-18 14:20:06 -05:00
Kim Woelders 39641e74a5 GIF loader: Fix segv on images without colormap.
Not sure what is the proper way to handle this.
For now we just fill the image with zeros.
2014-01-11 17:38:54 +01:00
Kim Woelders b7ad34abbc GIF loader: Simplify error handling.
Also:
- Fix memory leak when image data allocation fails.
- Some aux data arrays may as well be const.
2014-01-11 13:51:49 +01:00
Kim Woelders 6b24728fb8 Header file cleanups. 2013-12-22 05:10:44 +01:00
Kim Woelders c10f5a4fa5 Remove empty format.c/h. 2013-12-22 05:10:44 +01:00
Kim Woelders 7e513f5b87 Remove OS/2 support.
Looks incomplete and unmaintained.
2013-12-22 05:10:44 +01:00
Kim Woelders 1df8defbaa GIF loader: Fix for libgif version 5. 2013-12-22 05:10:43 +01:00
Kim Woelders df2c80ed07 Simplify some more and fix certain case of cpp > 2. 2013-08-05 14:38:38 +02:00
Kim Woelders 0d7f851f25 Cosmetics (reduce deep indentation level). 2013-08-04 19:58:33 +02:00
Kim Woelders 4a8aa48317 Deuglification. 2013-07-07 20:36:18 +02:00
Kim Woelders db33b8c6a1 Indent. 2013-07-07 20:36:18 +02:00
Kim Woelders fe82b9760c Autofoo updates.
- Eliminate deprecated AC_TRY_CPP.
- Use pkg-config in stead of freetype-config to get freetype info.
- Eliminate my_includes/my_libs.
- Clean up include paths.
2013-07-07 20:35:29 +02:00
Kim Woelders 842b550233 More warning fixes (64 bit). 2013-07-05 18:44:11 +02:00
Kim Woelders 306f42e0bd Silence compiler warnings (filters). 2013-07-03 16:57:04 +02:00
Kim Woelders 357852ebb9 Silence compiler warnings (loaders). 2013-07-03 16:53:21 +02:00
Kim Woelders 0c647a7f24 Silence compiler warnings (lib). 2013-07-03 16:51:22 +02:00
Kim Woelders 6e41fe2e1a Set warning options when using gcc. 2013-07-03 15:07:51 +02:00
Kim Woelders 7514ec5276 Minor optimisation (avoid bogus valgrind complaint). 2013-07-02 09:00:37 +02:00
Kim Woelders ad756ccacf Cosmetics for readability. 2013-07-02 08:57:04 +02:00
Kim Woelders eee318461d Fix drawing of closed polygons in certain situations (ticket 2309).
Drawing of the closing line could be skipped depending on the specific
vertex coordinates (and order).

Can't say that I undestand the code completely but this change seems
to fix the problem, and I don't think it can cause trouble.
2013-03-24 20:28:31 +01:00
Kim Woelders d943d1ebea Change INCLUDES to AM_CPPFLAGS.
INCLUDES is deprecated.
2013-03-24 20:28:31 +01:00
Kim Woelders a115ba3645 TGA loader: Fix for corrupt RLE format.
Patch by Matias Garcia/Ross Video.

SVN revision: 76919
2012-09-20 18:04:06 +00:00
Kim Woelders 8169598a08 Fix program linking (ticket 725).
SVN revision: 58695
2011-04-15 22:04:56 +00:00
Kim Woelders 4b12b9e154 PNM loader: Refactor around progress and exits.
SVN revision: 58520
2011-04-09 09:24:51 +00:00
Kim Woelders de93dc7e22 Fix loading of .pbm's (P4) when width is not a multiple of 8.
SVN revision: 58519
2011-04-09 09:24:48 +00:00
Kim Woelders 41c3a967d0 Indent (most) .c files.
SVN revision: 58518
2011-04-09 09:24:44 +00:00
Kim Woelders 4c55d2c3f6 Better image cache time stamp test.
SVN revision: 57918
2011-03-20 17:19:02 +00:00
Kim Woelders a1a018317a Fix pnm image loading in certain situations (ticket 721).
"It fails with "large" images, written with multiple pixels on the same line."

Patch by quentin.stievenart@gmail.com

SVN revision: 57697
2011-03-11 21:13:19 +00:00
Mike Frysinger 5983044ae4 png loader: do not hit "interlaced" member of the png ptr struct
this should work with libpng 1.[245].x ... did not check anything older than that though

patch by Thomas Klausner

SVN revision: 57171
2011-02-19 19:33:58 +00:00
Mike Frysinger d594895dba png loader: use png_jmpbuf() macro rather than hitting jmpbuf directly
this should work with libpng 1.[245].x ... did not check anything older than that though

patch by Thomas Klausner

SVN revision: 57170
2011-02-19 19:23:57 +00:00
Lucas De Marchi 24909ec041 Fix typos
"he->the" where appropriate



SVN revision: 52493
2010-09-20 17:09:13 +00:00
Lucas De Marchi 2ef97d2252 Fix common misspellings
Following misspellings were fixed:

adn->and
alwasy->always
arbitary->arbitrary
cant->can't
commerical->commercial
comprimise->compromise
consistant->consistent
dependant->dependent
didnt->didn't
doesnt->doesn't
enviroments->environments
foudn->found
fucntion->function
isnt->isn't
iwth->with
mroe->more
neccesary->necessary
onyl->only
paranthesis->parenthesis
parralel->parallel
refernces->references
seperate->separate
shoudl->should
soem->some
wasnt->wasn't
wiht->with
wokr->work




SVN revision: 52023
2010-09-09 03:31:04 +00:00
Kim Woelders 9daceb518d Fix imlib_render_image_part_on_drawable_at_size() ...
... when using color modifier and not scaling (ticket 576).

SVN revision: 51846
2010-09-02 21:19:49 +00:00
Lucas De Marchi 43def7af7b Revert and re-apply badnull patch
Revert previous patch generated by badnull.cocci script, and apply the new one.
The main difference is that assert and assert-like functions are not touched
anymore.




SVN revision: 51650
2010-08-26 01:34:13 +00:00
Lucas De Marchi 35e8e96a61 Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci

This should convert all cases where there's a comparison to NULL to simpler
forms. This patch applies the following transformations:

code before patch               ||code after patch
===============================================================

return a == NULL;                 return !a;

return a != NULL;                 return !!a;

func(a == NULL);                  func(!a);

func(a != NULL);                  func(!!a);

b = a == NULL;                    b = !a;

b = a != NULL;                    b = !!a;

b = a == NULL ? c : d;            b = !a ? c : d;

b = a != NULL ? c : d;            b = a ? c : d;


other cases:

a == NULL                         !a
a != NULL                         a




SVN revision: 51487
2010-08-21 13:52:25 +00:00
Lucas De Marchi 5962d9d66c Apply memset-calloc.cocci
Change calls to malloc + memset to calloc whenever an automatic conversion can
be done.

Possible candidates are not treated here, only the ones we can be sure the
conversion is safe.



SVN revision: 51078
2010-08-13 12:53:08 +00:00
Lucas De Marchi 96d043addc FORMATTING
* Remove vim modelines:
 find . -name '*.[chx]' -exec sed -i '/\/\*$/ {N;N;/ \* vim:ts/d}' \{\} \;
 find . -name '*.[chx]' -exec sed -i '/\/[\*\/] *vim:/d' \{\} \;

* Remove leading blank lines:
 find . -name '*.[cxh]' -exec sed -i '/./,$!d'

If you use vim, use this in your .vimrc:
set ts=8 sw=3 sts=8 expandtab cino=>5n-3f0^-2{2(0W1st0



SVN revision: 50816
2010-08-04 16:57:32 +00:00
Kim Woelders e34f1fe134 Fix reading tiff images with orientation other than ORIENTATION_TOPLEFT (ticket 563).
There are almost certainly still issues to be fixed, particularly
around progess() and certain combinations of orientation and tiling.

SVN revision: 50515
2010-07-26 18:14:10 +00:00
Kim Woelders 2c4149fee4 Avoid some duplicated code.
SVN revision: 50514
2010-07-26 18:14:08 +00:00
Kim Woelders c7388db2ae imlib2_view stuff.
- Add -s option to show scaled image.
- Handle WM_DELETE_WINDOW.
- Quit on keypress 'q'.
- Trivial cleanups.

SVN revision: 50513
2010-07-26 18:14:05 +00:00
Lucas De Marchi b2a826a680 Remove unneeded code with notnull.cocci script
The notnull.cocci script from Coccinelle finds places where you check if a
variable is NULL, but it's known not to be NULL. The check can be safely
removed. For example, this code would be caught by notnull:

if (!var) return;
if (var && var->fld) { ... }

It's needless to check again if var is not NULL because if it's in fact NULL,
it would have returned on the previous "if". This commit removes all the
trivial places where this pattern happens. Another patch will be generated for
the more complex cases.


SVN revision: 50241
2010-07-14 02:05:47 +00:00
Carsten Haitzler e5a280efc1 minor buglet - w * w - duh!
SVN revision: 47825
2010-04-08 01:29:29 +00:00
Kim Woelders d3bdadd623 Remove unused __imlib_FileField functions.
SVN revision: 47773
2010-04-05 18:36:50 +00:00
Kim Woelders dcddb36686 Remove .cvsignores.
SVN revision: 47214
2010-03-14 15:25:09 +00:00
Kim Woelders f8d9efaec5 Oops - forgot extern.
SVN revision: 46591
2010-02-27 18:14:25 +00:00
Kim Woelders d67ea1d096 Avoid cast.
SVN revision: 46335
2010-02-20 11:51:07 +00:00
Kim Woelders 08183bec3f Only check XShmAttach once in __imlib_ShmGetXImage().
SVN revision: 46334
2010-02-20 11:51:04 +00:00
Kim Woelders 7bf03a945c Fix excessive checking for shm extension in __imlib_GrabDrawableToRGBA().
SVN revision: 46333
2010-02-20 11:51:02 +00:00
Kim Woelders 2d25ea7c2a Fix for libpng-1.4 (png_check_sig->png_sig_cmp).
SVN revision: 46088
2010-02-11 20:01:54 +00:00
Kim Woelders d0d1a48672 Fix compiling .S files when using older automake (ticket 449).
SVN revision: 43354
2009-10-30 19:40:29 +00:00
Kim Woelders 4d1f5002b9 Use PNG_CFLAGS when compiling png loader (ticket 449).
SVN revision: 43332
2009-10-28 21:17:27 +00:00
Kim Woelders 9ca97f2001 Correct image dimension check (pixels are four bytes).
SVN revision: 43242
2009-10-24 06:29:21 +00:00
Carsten Haitzler 3bcb4f4746 handle modified dir date of 0
SVN revision: 42936
2009-10-07 12:07:53 +00:00
Kim Woelders dd93bae938 Fix build for x86 on x86_64.
As far as I can tell this fixes building on x86_64 with e.g.
'./configure --enable-mmx CFLAGS=-m32" or "rpmbuild --target i386 ..."
without breaking anything.


SVN revision: 41667
2009-08-10 16:26:20 +00:00
Kim Woelders 661a78dc57 Remove unimplemented imlib_clip_line prototype and documentation (ticket 379).
SVN revision: 41517
2009-07-27 21:35:25 +00:00
Kim Woelders 5619f9e257 Relax 8192 pixel dimension limit (ticket 361).
This time hopefully without buffer overflow issues.



SVN revision: 41516
2009-07-27 21:05:12 +00:00
Kim Woelders dedebfcc1a Relax 8192 pixel dimension limit (ticket 361).
SVN revision: 41412
2009-07-18 09:58:43 +00:00
Mike Frysinger ebab7f27bb imlib2: bumpmap: link against -lm since we use sin()/cos() functions
SVN revision: 41237
2009-07-03 01:30:49 +00:00
Kim Woelders 9686658a3c Fix imlib_font_query_size width calculation when there are undefined
codepoints (ticket 230).


SVN revision: 39306
2009-03-01 12:14:27 +00:00
Kim Woelders a7b230a6f8 Fix big endian bug in bmp loader (jogness, ticket 195).
SVN revision: 38767
2009-01-24 23:51:05 +00:00
Carsten Haitzler d4577b5d4e fix bufferoverflow in id3 loader.
SVN revision: 38642
2009-01-19 05:39:29 +00:00
Kim Woelders 6c5afe6fa1 Fix alignment error on amd64 (patch from Erik Boettcher).
SVN revision: 38402
2009-01-01 13:59:21 +00:00
Carsten Haitzler 6a427bd328 crash fix.
SVN revision: 37744
2008-11-22 09:27:45 +00:00
Kim Woelders 06a53a073d Refactor shm stuff.
SVN revision: 37378
2008-11-01 18:11:10 +00:00
Kim Woelders 5b60182d96 Don't build static libs for modules.
SVN revision: 37371
2008-11-01 10:17:38 +00:00
Kim Woelders 29442b80f5 Remove redundant BUILD_X11 tests, indent.
SVN revision: 37145
2008-10-26 13:59:07 +00:00
Kim Woelders 84cbf4bd3b Fix loading of jpeg files with 4 color components (kntriant, ticket 84).
SVN revision: 35970
2008-09-12 21:26:53 +00:00
Kim Woelders bb8b884ee5 Indent.
SVN revision: 35902
2008-09-09 20:13:02 +00:00