Commit Graph

1120 Commits

Author SHA1 Message Date
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 a085694ff0 Autofoo update (AC_PROG_LIBTOOL -> LT_INIT). 2014-12-16 20:30:37 +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
Mike Frysinger 5dde234b2d imlib2-config: delete old reference to @my_libs@
This was cleaned up a while ago, but this file was missed.

URL: https://bugs.gentoo.org/497894
2014-01-18 13:56:54 -05:00
Mike Frysinger dfb9521e8c simplify --enable-visibility-hiding handling
This also fixes the --disable-visibility-hiding flag so that it doesn't
turn visibility on.
2014-01-18 13:55:53 -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 31af56a040 1.4.6. 2013-12-21 13:41:59 +01:00
Kim Woelders ce0c14be10 Remove ChangeLog and obsolete rule to generate it. 2013-12-21 12:50:07 +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 e81eec2961 Don't set -std=gnu99.
Should not be needed since round() was implemented as macro.
2013-07-05 18:44:11 +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