summaryrefslogtreecommitdiff
path: root/media-libs/imlib
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /media-libs/imlib
reinit the tree, so we can have metadata
Diffstat (limited to 'media-libs/imlib')
-rw-r--r--media-libs/imlib/Manifest17
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-asneeded.patch38
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-bpp16-CVE-2007-3568.patch11
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-fix-rendering.patch105
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-giflib51-1.patch122
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-giflib51-2.patch107
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-libpng15.patch142
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-no-LDFLAGS-in-pc.patch16
-rw-r--r--media-libs/imlib/files/imlib-1.9.15-underlinking-test.patch10
-rw-r--r--media-libs/imlib/files/imlib-1.9.15.patch70
-rw-r--r--media-libs/imlib/files/imlib-security.patch510
-rw-r--r--media-libs/imlib/imlib-1.9.15-r4.ebuild68
-rw-r--r--media-libs/imlib/imlib-1.9.15-r5.ebuild72
-rw-r--r--media-libs/imlib/metadata.xml8
14 files changed, 1296 insertions, 0 deletions
diff --git a/media-libs/imlib/Manifest b/media-libs/imlib/Manifest
new file mode 100644
index 000000000000..d94baa9f9d6f
--- /dev/null
+++ b/media-libs/imlib/Manifest
@@ -0,0 +1,17 @@
+AUX imlib-1.9.15-asneeded.patch 1124 SHA256 bdd4b6f4a578fa22bbf5ec45cabcd8e016efb1103215847752f317f68f76654f SHA512 ed12ad7420622dcde29d287f258e6d7257d126c9f227d9ea0f1e6d00f83ffa0c5ff25912d7eb94352a3b92cefe79c0317d2bed3179ae74348b91e9f3293bd557 WHIRLPOOL 6a1e8e246824c7766b189560640ad0d41198ee40f82784eeb992f80f63c637c8fe94234fb014752f83ba851439030852745e3aa7965fa15266d664ae9980a05f
+AUX imlib-1.9.15-bpp16-CVE-2007-3568.patch 461 SHA256 6f6d2e0ceaff5939255c4f9583c0a4bd88ce20b88407acd388f39104e28aae53 SHA512 9a60cf535bb58240de01c73afe43c4c24c0c15fab3f8d48d4571795ff717c4670d1465ffc0c8f9db5144ef241fccb7477fdf43240d18e53384c0888a2b24e7c2 WHIRLPOOL 741b24981c997385e2b1c5f9fe834dd35389e33ac0d765a85ff60fff36175417e29ba04bee757d627a42f8b648f5dbdf02e94392bda7b5a3f9045b3d503d409f
+AUX imlib-1.9.15-fix-rendering.patch 3263 SHA256 7f5f8967ec52658e776a0a60a3a3c93d367ccf877d92569a9313e78bbd510604 SHA512 4e94da8de3f18b711bdfcf4184dbc2220ef566aa61b72c6139e490e55051b3090dc5330929b218f6fab1764c8c2ee8acdd630a0c64010b56b4b4f1b8c55c3f89 WHIRLPOOL d25d7be59ad63e97a8f12baf41532d1da4ea0b8cb004074c681e08e5c8c473fa4b68d46285e5cf7361601bb99d42b523c1299ffe5bdd7c69b120d8559de48d03
+AUX imlib-1.9.15-giflib51-1.patch 3284 SHA256 6c9e27d4adb781a682bb6a161e23f9704ad798251c9ea095b13b1d85bc97d9e4 SHA512 ceb74e811300d7233019bcd9f20baf711c5f778e59cc72f56b954845594841b42ee8958eec77ee9ffe6f2a6002a6726c96d5a93463cdc18f5b593ce5333798a0 WHIRLPOOL 9d12ef7ab1264744ccf462841c21a072a9adf12884e86ed1897c99285c598a5e67cb23348d897fa506bd641652cd7cff3c2efabef58e84a65bbf699c6c2d560d
+AUX imlib-1.9.15-giflib51-2.patch 2847 SHA256 bbb55ccfc6a04491620294637d216af7b7ca329427f1a95417b8e63175ede2b4 SHA512 e7c56f6f30594f35dc240bbdb57965f9036e688bede544a937f536de10f598eb881be315d2cebf3a7c27ae5ab6c5a4627d16c948c93a04bc56f6bb1f6b31bb34 WHIRLPOOL 956ac2e0e57e7ab6745be1c32792f233ef2ba4a29f937eec42bfa23064d5b695e796c95ba09f8adb856d8faee5720b1499ca515cb0aaa07d4204ba6090c465ea
+AUX imlib-1.9.15-libpng15.patch 3801 SHA256 f203fc5d6dc64223263f5678cec2d2dd80435641db770cec8988aa1961c72d0e SHA512 a25cbafb9510d9f4315306f258278b2a8944e490137046c47b0e04363fb3167f03d123f3e22b142adf594350c1ffad2084fe635b1b2c88a62568582a253303ee WHIRLPOOL 902f8cfb75fda77481b65ef80c2c431ed3f62265e7731694e552b4e9f9a02fc9670bfe94b2bdcbcc5d093b90df3a369e73751defd94cc1298da5ca311799054e
+AUX imlib-1.9.15-no-LDFLAGS-in-pc.patch 892 SHA256 f37eccfee50b7fc2ba9f2a7ed2afdb67daf0cf139542fd5db8a65432ca16c806 SHA512 7b23a8c00b13f63f07526d97c4d098f2c44e983add0be685e14d2a9e1893458735a63b0c6bbd7d1b56960d83695b1ebd99a6d9f63309ae0bac3b138f6c1f80e9 WHIRLPOOL eb16031fa103d65abdfaea9b4d5f3c1c91086fe6c997a76f64f1206ea55d01beec577cdf93925d20ad25812e17c48b4c7a6e624c73e25789ffd969ddaf9f45ae
+AUX imlib-1.9.15-underlinking-test.patch 475 SHA256 f876fc3cc56af9f7e346bcafa3a62c5b4f8fefb0896fa33b832733fded7b6b78 SHA512 93fea49272e4e7e71d7d0115be8132d6169910d633fd2aeae20b71f933be7596b32e29ada0198733ca4f65c216eedc95c420607c2b51e32cd81b9d7938f022a3 WHIRLPOOL a8dc9b55153a085901ee2ce2a94bda92ac6ba2575b2e0713fa0d55217e7178ec88d7a415f8f06fc63a34f2d8e4dc2c9e45c676a8b70778870c9698e13d1bdeaa
+AUX imlib-1.9.15.patch 2253 SHA256 43dd12dae7913475f968f35a4fa4b1ef4670451e58c712cbd6e5460f20fc9197 SHA512 4de2fb6e28a6b9da3f474153ef618aad199d1fe6e365670d3d2070afa5b123597f108cac0972454dbcf38b8d84a9a6eb8f011d92a9d754248af41e3abd799b6d WHIRLPOOL d5417943c318d6d9371f5826ccaa6ccee9d84ac128db5ea46ae7a570e9a64fba2de7ff0fbc6a935026defc5ef0c0a45c62ca0459c0f1211c96cf1451cc653bb2
+AUX imlib-security.patch 13040 SHA256 d67a7faa2dba8d361cf25b6fc8125c1da92f25b612bffe909daacdeda577dd57 SHA512 a75537267e9e276920fbc0360cd4832f727c6c9857401889bdb1466f3088c98e5ea2ef84a94a5873a3c12dda0b9aed36a5e2039fece87e51154a3b773d97aa5c WHIRLPOOL 5f892847f9aa86896ecefc50d77575066a4ae1e573a9d631247a104a8d51d1f907cfb405a5d19f3a738912140900843c916661399e469b5f44c5ac5efdab6121
+DIST gtk-1-for-imlib.m4.bz2 2742 SHA256 e024d822d64819e23f7ad7c8283086ffd1e112b859b4669f1624dda1c56d8c47 SHA512 83708af1c7d7cf10960463b785bad096d77e985be5907dd59c73c2cb86c4b89fb5453a02ffddca1519185b91d205dbd96c4c4c1df4da4b67e64bad413cd8a40e WHIRLPOOL 5490f53e1559b9f505cd0ac4b8d0a9c74d8cb323daf4e048b4123725b1f1c12dae936595a0173cdb9d74e2377f6c8942d14e783977d91e6d920342bd5d2e724e
+DIST imlib-1.9.15.tar.bz2 683242 SHA256 4e6a270308a9ae16586bfc133c1a3dfb2e56f431edb66aaa3a80e36e5ed84ce0 SHA512 f50d9141b3c54b44921aa09c0a5ea848aefaa904efdd6da132dace42604671f8dbd3e4b71a596f054f0db4525ba2002864b5e5b21f8805cf1b5514b661ac254a WHIRLPOOL b9127c602a69eb52ab2bbe66733e8d35c8311a6decf569dd3d63dcff8d1d69ca8ed5572fac4ab795685beef46fb039a68325b70e697e7257d4ee92ad2c4edde2
+EBUILD imlib-1.9.15-r4.ebuild 2098 SHA256 ca5b793f387afbb75e6da0dd34c4625630f02345162c8bd4c6a6af0ab040d7ee SHA512 57b6c5a17dcdcba92096d3bdd130e5eec737d01e85884934440957e60c5c43c3060d540082ec070a342148d508f920dbf05b6843b2123bb72dabce3cacaa7e4e WHIRLPOOL 1ba58ed51a8d1c2388f4bad40d11d78662085b9e2bfba8656fbda0c85a5cfcd02f8f205fdb8d87d5942e7df6d65422a001b4390d7a51e52522ed37f8a2603466
+EBUILD imlib-1.9.15-r5.ebuild 2153 SHA256 866f2d139cd954a4a2c5ea4b11900115d1d054b556ca467df01c51530ed34717 SHA512 6850be17155da958d736adf291cf3f571b49b5997ff4940891cff3f6899147e7f7384edb34dfc9943db1d6893c3a9a250f8728be5a57779380b05307bb1305d6 WHIRLPOOL 1350d6a1bc652995c19845e846fba3972d240ccffa359b54079feb69f19bfc4961aadf2d0a117c7784c75e3bd6cbc783ac41e2f60a689d7e3972e72ec9e68cfd
+MISC ChangeLog 4019 SHA256 9a8368b0f9d69b0b0303094e0065199b02d8d320b8f0d1677cf91eaada7ac1a3 SHA512 07fbf045df5dc88facd97087cdb8ac506638a5e694d4ec74f4699c7fa95163971724f124f721aaeda1d541905f5b456f3d897a342754b3411aae890cc23846cd WHIRLPOOL 2a8fe998037d8ee318217fdc75f5dfcd6ab7bc507a5119b18732ab4214bb6d1776ee380fd149a971b45ec9a4fbdc111bb354a1f747b167ea99c6c6e14a236f05
+MISC ChangeLog-2015 12500 SHA256 0da8ccccdcabac7be22e3fcda78638659a2709d98ef5072e4767bd65e513b505 SHA512 d25bf74c3c744280b62b217ee8cbc94d5705c194f520cf18863d5d76b80f9ae6b2ea92001c7fac0a36b1391d9bcb389c3b14d07d14493b16ead3ff9e105246ee WHIRLPOOL d82a0c6b07fbed113cf31ed167fda7f849a8fb6cf3357508076e865f98b63334d4e18317bb3abbf6cdb3ace03c94e56c7dd23020d645112992dbadd40dce7b0b
+MISC metadata.xml 255 SHA256 3e7137870fc49956d79719e3dfe029775cbaaa097e85748c139713c46fcd1798 SHA512 b7bc93530a1726c2d4dfbc71ae29cfbb57712fd9fdd2e76fd52f35ab4368cba0497b50145d1527a3b79e465d459a380821bb1371a01c2e915dc9adc6c7fafd5f WHIRLPOOL 392188d7e069f1720be9329edfb31b11b176bf0c411023b2ceeaeabef1cacf842d70657a2a14ac2ddabbdad70a304275f3b587e9bcdfe77be63a0092e370252c
diff --git a/media-libs/imlib/files/imlib-1.9.15-asneeded.patch b/media-libs/imlib/files/imlib-1.9.15-asneeded.patch
new file mode 100644
index 000000000000..d9ccde7bdfcd
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-asneeded.patch
@@ -0,0 +1,38 @@
+This code is broken with the newer libtool. Just dropping it is more or less
+safe as in any case if libtool does not supports shared libraries it'll issue
+an error...
+
+Adding include is necessary for gcc-4.3.
+
+--- a/configure.in 2008-07-16 09:18:35 +0000
++++ b/configure.in 2008-07-16 09:18:43 +0000
+@@ -61,6 +61,7 @@
+ AC_TRY_RUN([
+ #include <glib.h>
+ #include <gmodule.h>
++#include <stdlib.h>
+ main ()
+ {
+ if (g_module_supported ())
+@@ -74,21 +74,6 @@
+ CFLAGS="$oCFLAGS"
+ fi
+
+-dnl Now we check to see if our libtool supports shared lib deps
+-dnl (in a rather ugly way even)
+-builddir=`pwd`
+-if $dynworks; then
+- imlib_libtool_config="$builddir/libtool --config"
+- imlib_deplibs_check=`$imlib_libtool_config | \
+- grep '^[[a-z_]]*check[[a-z_]]*_method=[['\''"]]' | \
+- sed 's/.*[['\''"]]\(.*\)[['\''"]]$/\1/'`
+- if test "x$imlib_deplibs_check" = "xnone" || \
+- test "x$imlib_deplibs_check" = "xunknown" || \
+- test "x$imlib_deplibs_check" = "x"; then
+- dynworks=false
+- fi
+-fi
+-
+ if $dynworks; then
+ AC_DEFINE(USE_GMODULE, 1, [ ])
+ GMODULE_LIBS="`glib-config --libs gmodule`"
diff --git a/media-libs/imlib/files/imlib-1.9.15-bpp16-CVE-2007-3568.patch b/media-libs/imlib/files/imlib-1.9.15-bpp16-CVE-2007-3568.patch
new file mode 100644
index 000000000000..308f9abc044d
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-bpp16-CVE-2007-3568.patch
@@ -0,0 +1,11 @@
+--- a/Imlib/load.c.orig 2007-08-13 23:06:20.000000000 -0300
++++ b/Imlib/load.c 2007-08-13 23:06:51.000000000 -0300
+@@ -645,7 +645,7 @@
+ planes = (int)word;
+ fread(&word, 2, 1, file);
+ bpp = (int)word;
+- if (bpp != 1 && bpp != 4 && bpp != 8 && bpp && 16 && bpp != 24 && bpp != 32)
++ if (bpp != 1 && bpp != 4 && bpp != 8 && bpp != 16 && bpp != 24 && bpp != 32)
+ {
+ fprintf(stderr, "IMLIB ERROR: unknown bitdepth in file\n");
+ return NULL;
diff --git a/media-libs/imlib/files/imlib-1.9.15-fix-rendering.patch b/media-libs/imlib/files/imlib-1.9.15-fix-rendering.patch
new file mode 100644
index 000000000000..6212ed31428e
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-fix-rendering.patch
@@ -0,0 +1,105 @@
+Michel Dänzer <daenzer AT debian.org>
+
+* The boolean value returned via the last parameter to XShmQueryVersion()
+ isn't honoured everywhere.
+* The init functions that take parameters allow the caller to enable shared
+ pixmaps when they aren't supported (or disabled by configuration files).
+
+
+These result in incorrect rendering when the MIT-SHM extension doesn't support
+shared pixmaps, e.g. using EXA with current versions of Xorg.
+
+http://bugs.gentoo.org/show_bug.cgi?id=197489
+
+diff -up -ru imlib-1.9.15.orig/gdk_imlib/misc.c imlib-1.9.15/gdk_imlib/misc.c
+--- imlib-1.9.15.orig/gdk_imlib/misc.c 2002-03-04 18:06:32.000000000 +0100
++++ imlib-1.9.15/gdk_imlib/misc.c 2007-10-28 14:00:04.000000000 +0100
+@@ -674,6 +674,10 @@ gdk_imlib_init_params(GdkImlibInitParams
+ visual = gdk_rgb_get_visual();
+ id->x.visual = GDK_VISUAL_XVISUAL(visual); /* the visual type */
+ id->x.depth = visual->depth; /* the depth of the screen in bpp */
++
++ id->x.shm = 0;
++ id->x.shmp = 0;
++ id->max_shm = 0;
+ #ifdef HAVE_SHM
+ if (XShmQueryExtension(id->x.disp))
+ {
+@@ -689,17 +693,14 @@ gdk_imlib_init_params(GdkImlibInitParams
+ id->x.last_xim = NULL;
+ id->x.last_sxim = NULL;
+ id->max_shm = 0x7fffffff;
+- if (XShmPixmapFormat(id->x.disp) == ZPixmap)
++ if ((XShmPixmapFormat(id->x.disp) == ZPixmap) &&
++ (pm == True))
+ id->x.shmp = 1;
+ }
+ }
+ }
+- else
+ #endif
+- {
+- id->x.shm = 0;
+- id->x.shmp = 0;
+- }
++
+ id->cache.on_image = 0;
+ id->cache.size_image = 0;
+ id->cache.num_image = 0;
+@@ -935,8 +936,8 @@ gdk_imlib_init_params(GdkImlibInitParams
+ }
+ if (p->flags & PARAMS_SHAREDPIXMAPS)
+ {
+- if (id->x.shm)
+- id->x.shmp = p->sharedpixmaps;
++ if (!p->sharedpixmaps)
++ id->x.shmp = 0;
+ }
+ if (p->flags & PARAMS_PALETTEOVERRIDE)
+ override = p->paletteoverride;
+diff -up -ru imlib-1.9.15.orig/Imlib/misc.c imlib-1.9.15/Imlib/misc.c
+--- imlib-1.9.15.orig/Imlib/misc.c 2004-09-21 02:22:59.000000000 +0200
++++ imlib-1.9.15/Imlib/misc.c 2007-10-28 14:00:23.000000000 +0100
+@@ -675,6 +675,10 @@ Imlib_init_with_params(Display * disp, I
+ id->x.root = DefaultRootWindow(disp); /* the root window id */
+ id->x.visual = DefaultVisual(disp, id->x.screen); /* the visual type */
+ id->x.depth = DefaultDepth(disp, id->x.screen); /* the depth of the screen in bpp */
++
++ id->x.shm = 0;
++ id->x.shmp = 0;
++ id->max_shm = 0;
+ #ifdef HAVE_SHM
+ if (XShmQueryExtension(id->x.disp))
+ {
+@@ -690,17 +694,14 @@ Imlib_init_with_params(Display * disp, I
+ id->x.last_xim = NULL;
+ id->x.last_sxim = NULL;
+ id->max_shm = 0x7fffffff;
+- if (XShmPixmapFormat(id->x.disp) == ZPixmap)
++ if ((XShmPixmapFormat(id->x.disp) == ZPixmap &&
++ (pm == True)))
+ id->x.shmp = 1;
+ }
+ }
+ }
+- else
+ #endif
+- {
+- id->x.shm = 0;
+- id->x.shmp = 0;
+- }
++
+ id->cache.on_image = 0;
+ id->cache.size_image = 0;
+ id->cache.num_image = 0;
+@@ -952,8 +953,8 @@ Imlib_init_with_params(Display * disp, I
+ }
+ if (p->flags & PARAMS_SHAREDPIXMAPS)
+ {
+- if (id->x.shm)
+- id->x.shmp = p->sharedpixmaps;
++ if (!p->sharedpixmaps)
++ id->x.shmp = 0;
+ }
+ if (p->flags & PARAMS_PALETTEOVERRIDE)
+ override = p->paletteoverride;
diff --git a/media-libs/imlib/files/imlib-1.9.15-giflib51-1.patch b/media-libs/imlib/files/imlib-1.9.15-giflib51-1.patch
new file mode 100644
index 000000000000..d0e3ac7d8d2c
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-giflib51-1.patch
@@ -0,0 +1,122 @@
+diff -Nru imlib-1.9.15.old/gdk_imlib/io-gif.c imlib-1.9.15/gdk_imlib/io-gif.c
+--- imlib-1.9.15.old/gdk_imlib/io-gif.c 2014-05-28 13:54:48.860293627 +0100
++++ imlib-1.9.15/gdk_imlib/io-gif.c 2014-05-28 13:58:29.992185729 +0100
+@@ -1,8 +1,10 @@
+ #include <config.h>
+ #include "gdk_imlib.h"
+ #include "gdk_imlib_private.h"
++#include <gifutil.h>
+
+ #ifndef HAVE_LIBGIF
++/*------------------------*/
+ unsigned char loader_gif (FILE *f, int *w, int *h, int *t)
+ {
+ return NULL;
+@@ -43,14 +45,14 @@
+ {
+ if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
+ {
+- PrintGifError();
++ _PrintGifError(gif);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
+ {
+ if (DGifGetImageDesc(gif) == GIF_ERROR)
+ {
+- PrintGifError();
++ _PrintGifError(gif);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ *w = gif->Image.Width;
+diff -Nru imlib-1.9.15.old/gifutil.h imlib-1.9.15/gifutil.h
+--- imlib-1.9.15.old/gifutil.h 1970-01-01 01:00:00.000000000 +0100
++++ imlib-1.9.15/gifutil.h 2014-05-28 13:57:45.019424755 +0100
+@@ -0,0 +1,26 @@
++#ifndef __GIFUTIL_H__
++#define __GIFUTIL_H__
++
++static void
++_PrintGifError(GifFileType *gif)
++{
++ /* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
++ /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
++#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
++ ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
++ /* Static string actually, hence the const char* cast */
++
++#if GIFLIB_MAJOR >= 5
++ const char* gifliberr = (const char*) GifErrorString(gif->Error);
++#else
++ const char* gifliberr = (const char*) GifErrorString();
++#endif
++ if (gifliberr == NULL)
++ gifliberr = "Unknown error";
++ fprintf(stderr, "%s\n", gifliberr);
++#else
++ PrintGifError();
++#endif
++}
++
++#endif
+diff -Nru imlib-1.9.15.old/Imlib/load.c imlib-1.9.15/Imlib/load.c
+--- imlib-1.9.15.old/Imlib/load.c 2014-05-28 13:54:49.008295568 +0100
++++ imlib-1.9.15/Imlib/load.c 2014-05-28 14:00:21.321983945 +0100
+@@ -3,6 +3,7 @@
+ #include "Imlib.h"
+ #include "Imlib_private.h"
+ #include <setjmp.h>
++#include <gifutil.h>
+
+ #define G_MAXINT ((int) 0x7fffffff)
+
+@@ -431,6 +432,8 @@
+ #endif /* HAVE_LIBTIFF */
+
+ #ifdef HAVE_LIBGIF
++/*------------------------*/
++/*------------------------*/
+ unsigned char *
+ _LoadGIF(ImlibData * id, FILE *f, int *w, int *h, int *t)
+ {
+@@ -454,22 +457,38 @@
+ fd = fileno(f);
+ /* Apparently rewind(f) isn't sufficient */
+ lseek(fd, (long) 0, 0);
++
++#if GIFLIB_MAJOR >= 5
++ int errCode = 0;
++
++ gif = DGifOpenFileHandle(fd, &errCode);
++ if (!gif)
++ {
++ const char* gifliberr = (const char*) GifErrorString(errCode);
++ if (gifliberr == NULL)
++ gifliberr = "Unknown error";
++ fprintf(stderr, "%s\n", gifliberr);
++ return NULL;
++ }
++#else
+ gif = DGifOpenFileHandle(fd);
+
+ if (!gif)
+ return NULL;
++#endif
++
+ do
+ {
+ if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
+ {
+- PrintGifError();
++ _PrintGifError(gif);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
+ {
+ if (DGifGetImageDesc(gif) == GIF_ERROR)
+ {
+- PrintGifError();
++ _PrintGifError(gif);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ *w = gif->Image.Width;
diff --git a/media-libs/imlib/files/imlib-1.9.15-giflib51-2.patch b/media-libs/imlib/files/imlib-1.9.15-giflib51-2.patch
new file mode 100644
index 000000000000..7911e7c7e40d
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-giflib51-2.patch
@@ -0,0 +1,107 @@
+diff -Nru imlib-1.9.15.old/gifutil.h imlib-1.9.15/gifutil.h
+--- imlib-1.9.15.old/gifutil.h 2015-02-03 00:53:09.742075193 +0000
++++ imlib-1.9.15/gifutil.h 2015-02-05 19:24:09.848783163 +0000
+@@ -2,7 +2,7 @@
+ #define __GIFUTIL_H__
+
+ static void
+-_PrintGifError(GifFileType *gif)
++_PrintGifError(int errorCode)
+ {
+ /* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
+ /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
+@@ -11,7 +11,7 @@
+ /* Static string actually, hence the const char* cast */
+
+ #if GIFLIB_MAJOR >= 5
+- const char* gifliberr = (const char*) GifErrorString(gif->Error);
++ const char* gifliberr = (const char*) GifErrorString(errorCode);
+ #else
+ const char* gifliberr = (const char*) GifErrorString();
+ #endif
+diff -Nru imlib-1.9.15.old/Imlib/load.c imlib-1.9.15/Imlib/load.c
+--- imlib-1.9.15.old/Imlib/load.c 2015-02-03 00:53:09.742075193 +0000
++++ imlib-1.9.15/Imlib/load.c 2015-02-05 19:30:12.847147998 +0000
+@@ -434,6 +434,19 @@
+ #ifdef HAVE_LIBGIF
+ /*------------------------*/
+ /*------------------------*/
++void
++_CloseGIF(GifFileType *gif)
++{
++#if GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1)
++ int errCode = 0;
++
++ if (DGifCloseFile(gif, &errCode) != GIF_OK)
++ _PrintGifError(errCode);
++#else
++ DGifCloseFile(gif);
++#endif
++}
++
+ unsigned char *
+ _LoadGIF(ImlibData * id, FILE *f, int *w, int *h, int *t)
+ {
+@@ -464,10 +477,7 @@
+ gif = DGifOpenFileHandle(fd, &errCode);
+ if (!gif)
+ {
+- const char* gifliberr = (const char*) GifErrorString(errCode);
+- if (gifliberr == NULL)
+- gifliberr = "Unknown error";
+- fprintf(stderr, "%s\n", gifliberr);
++ _PrintGifError(errCode);
+ return NULL;
+ }
+ #else
+@@ -481,14 +491,14 @@
+ {
+ if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
+ {
+- _PrintGifError(gif);
++ _PrintGifError(gif->Error);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
+ {
+ if (DGifGetImageDesc(gif) == GIF_ERROR)
+ {
+- _PrintGifError(gif);
++ _PrintGifError(gif->Error);
+ rec = TERMINATE_RECORD_TYPE;
+ }
+ *w = gif->Image.Width;
+@@ -500,13 +510,13 @@
+ rows = malloc(*h * sizeof(GifRowType *));
+ if (!rows)
+ {
+- DGifCloseFile(gif);
++ _CloseGIF(gif);
+ return NULL;
+ }
+ data = _imlib_malloc_image(*w, *h);
+ if (!data)
+ {
+- DGifCloseFile(gif);
++ _CloseGIF(gif);
+ free(rows);
+ return NULL;
+ }
+@@ -517,7 +527,7 @@
+ rows[i] = malloc(*w * sizeof(GifPixelType));
+ if (!rows[i])
+ {
+- DGifCloseFile(gif);
++ _CloseGIF(gif);
+ for (i = 0; i < *h; i++)
+ if (rows[i])
+ free(rows[i]);
+@@ -606,7 +616,7 @@
+ }
+ }
+ }
+- DGifCloseFile(gif);
++ _CloseGIF(gif);
+ for (i = 0; i < *h; i++)
+ free(rows[i]);
+ free(rows);
diff --git a/media-libs/imlib/files/imlib-1.9.15-libpng15.patch b/media-libs/imlib/files/imlib-1.9.15-libpng15.patch
new file mode 100644
index 000000000000..353960897f1c
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-libpng15.patch
@@ -0,0 +1,142 @@
+--- a/gdk_imlib/io-png.c
++++ b/gdk_imlib/io-png.c
+@@ -40,13 +40,13 @@
+ return NULL;
+ }
+
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+ }
+
+- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+@@ -275,13 +275,13 @@
+ return NULL;
+ }
+
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+ }
+
+- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+@@ -301,6 +301,9 @@
+ /* Setup Translators */
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
+ png_set_expand(png_ptr);
++ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
++ png_set_expand(png_ptr);
++
+ png_set_strip_16(png_ptr);
+ png_set_packing(png_ptr);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+@@ -440,13 +443,13 @@
+ return NULL;
+ }
+
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+ }
+
+- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+@@ -635,7 +638,7 @@
+ png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+ return 0;
+ }
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ fclose(f);
+ png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+--- a/Imlib/load.c
++++ b/Imlib/load.c
+@@ -197,12 +197,12 @@
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return NULL;
+ }
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+ }
+- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+@@ -260,7 +260,8 @@
+ png_read_image(png_ptr, lines);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ ptr = data;
+- if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
++ if (color_type == PNG_COLOR_TYPE_GRAY
++ || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ {
+ for (y = 0; y < *h; y++)
+ {
+@@ -285,6 +286,7 @@
+ }
+ }
+ }
++#if 0
+ else if (color_type == PNG_COLOR_TYPE_GRAY)
+ {
+ for (y = 0; y < *h; y++)
+@@ -300,6 +302,7 @@
+ }
+ }
+ }
++#endif
+ else
+ {
+ for (y = 0; y < *h; y++)
+--- a/Imlib/save.c
++++ b/Imlib/save.c
+@@ -342,7 +342,7 @@
+ png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+ return 0;
+ }
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ fclose(f);
+ png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+--- a/Imlib/utils.c
++++ b/Imlib/utils.c
+@@ -1981,14 +1981,13 @@
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return NULL;
+ }
+-
+- if (setjmp(png_ptr->jmpbuf))
++ if (setjmp(png_jmpbuf(png_ptr)))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
+ }
+
+- if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
++ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB_ALPHA)
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ return NULL;
diff --git a/media-libs/imlib/files/imlib-1.9.15-no-LDFLAGS-in-pc.patch b/media-libs/imlib/files/imlib-1.9.15-no-LDFLAGS-in-pc.patch
new file mode 100644
index 000000000000..9a1ade9879ee
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-no-LDFLAGS-in-pc.patch
@@ -0,0 +1,16 @@
+Detected by Gentoo QA check:
+
+ * QA Notice: pkg-config files with wrong LDFLAGS detected:
+ * /usr/lib32/pkgconfig/imlib.pc:Libs: -L${libdir} -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -lImlib -ljpeg -ltiff -lgif -lpng -lz -lm -lXext -lSM -lICE -lXext -lX11
+ * /usr/lib64/pkgconfig/imlib.pc:Libs: -L${libdir} -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -lImlib -ljpeg -ltiff -lgif -lpng -lz -lm -lXext -lSM -lICE -lXext -lX11
+diff --git a/imlib.pc.in b/imlib.pc.in
+index 0a6f276..dc1ef7d 100644
+--- a/imlib.pc.in
++++ b/imlib.pc.in
+@@ -9,5 +9,5 @@ Name: Imlib
+ Description: An image loading and rendering library for X11R6
+ Version: @VERSION@
+ Requires:
+-Libs: -L${libdir} @LDFLAGS@ -lImlib @SUPPORT_LIBS@ @X_LIBS@ @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
++Libs: -L${libdir} -lImlib @SUPPORT_LIBS@ @X_LIBS@ @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@
+ Cflags: -I${includedir} @X_CFLAGS@
diff --git a/media-libs/imlib/files/imlib-1.9.15-underlinking-test.patch b/media-libs/imlib/files/imlib-1.9.15-underlinking-test.patch
new file mode 100644
index 000000000000..aa52557e25a2
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15-underlinking-test.patch
@@ -0,0 +1,10 @@
+https://bugs.gentoo.org/show_bug.cgi?id=367645
+by Greg Turner
+diff -urpN imlib-1.9.15.orig/Imlib/Makefile.am imlib-1.9.15/Imlib/Makefile.am
+--- imlib-1.9.15.orig/Imlib/Makefile.am 2004-09-20 17:22:59.000000000 -0700
++++ imlib-1.9.15/Imlib/Makefile.am 2013-10-08 02:48:53.772197627 -0700
+@@ -44,3 +44,3 @@ INCLUDES = -I. -I$(srcdir) -I.. -I$(srcd
+ check_PROGRAMS = t-load
+
+-t_load_LDADD = libImlib.la
++t_load_LDADD = libImlib.la $(X_PRE_LIBS) $(X_LIBS) -lX11 $(X_EXTRA_LIBS)
diff --git a/media-libs/imlib/files/imlib-1.9.15.patch b/media-libs/imlib/files/imlib-1.9.15.patch
new file mode 100644
index 000000000000..c78aea9ad98f
--- /dev/null
+++ b/media-libs/imlib/files/imlib-1.9.15.patch
@@ -0,0 +1,70 @@
+diff -ur imlib-1.9.15.orig/configure.in imlib-1.9.15/configure.in
+--- imlib-1.9.15.orig/configure.in 2004-09-23 04:13:45.000000000 +0300
++++ imlib-1.9.15/configure.in 2007-02-05 23:43:18.000000000 +0200
+@@ -17,11 +17,26 @@
+ dnl incase it is broken for example.
+ AC_ARG_ENABLE(shm, [ --enable-shm support shared memory if available [default=yes]], echo $enable_shm, enable_shm="yes")
+
++AC_ARG_ENABLE(gdk, [ --enable-gdk enable gdk_imlib compilation [default=yes]],[
++ if test x$enableval = xyes; then
++ disable_gdk="no"
++ else
++ disable_gdk="yes"
++ fi],disable_gdk=no)
++
++if test x$disable_gdk = xno; then
++ AC_MSG_RESULT(no)
++
+ AM_PATH_GTK(1.2.1,[
+ GDK_IMLIB="gdk_imlib utils"],[
+ GDK_IMLIB=""
+ AC_MSG_WARN([*** gdk_imlib will not be built ***])])
+
++else
++ AC_MSG_RESULT(yes)
++ GDK_IMLIB=""
++fi
++
+ AC_MSG_CHECKING(whether to build gmodulized imlib)
+
+ AC_ARG_ENABLE(modules, [ --disable-modules Disables dynamic module loading],[
+diff -ur imlib-1.9.15.orig/imlib-config.in imlib-1.9.15/imlib-config.in
+--- imlib-1.9.15.orig/imlib-config.in 2004-08-27 19:03:11.000000000 +0300
++++ imlib-1.9.15/imlib-config.in 2007-02-05 23:46:34.000000000 +0200
+@@ -46,15 +46,9 @@
+ echo @VERSION@
+ ;;
+ --cflags)
+- if test @includedir@ != /usr/include ; then
+- includes=-I@includedir@
+- fi
+ echo $includes @X_CFLAGS@
+ ;;
+ --cflags-gdk)
+- if test @includedir@ != /usr/include ; then
+- includes=-I@includedir@
+- fi
+ echo `@GTK_CONFIG@ --cflags` $includes @X_CFLAGS@
+ ;;
+ --libs)
+diff -ur imlib-1.9.15.orig/imlib.m4 imlib-1.9.15/imlib.m4
+--- imlib-1.9.15.orig/imlib.m4 2004-08-27 19:03:11.000000000 +0300
++++ imlib-1.9.15/imlib.m4 2007-02-05 23:42:57.000000000 +0200
+@@ -6,7 +6,7 @@
+ dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+ dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS
+ dnl
+-AC_DEFUN(AM_PATH_IMLIB,
++AC_DEFUN([AM_PATH_IMLIB],
+ [dnl
+ dnl Get the cflags and libraries from the imlib-config script
+ dnl
+@@ -164,7 +164,7 @@
+ ])
+
+ # Check for gdk-imlib
+-AC_DEFUN(AM_PATH_GDK_IMLIB,
++AC_DEFUN([AM_PATH_GDK_IMLIB],
+ [dnl
+ dnl Get the cflags and libraries from the imlib-config script
+ dnl
diff --git a/media-libs/imlib/files/imlib-security.patch b/media-libs/imlib/files/imlib-security.patch
new file mode 100644
index 000000000000..c820270d47e1
--- /dev/null
+++ b/media-libs/imlib/files/imlib-security.patch
@@ -0,0 +1,510 @@
+diff -urN imlib-1.9.13.orig/Imlib/load.c imlib-1.9.13/Imlib/load.c
+--- imlib-1.9.13.orig/Imlib/load.c Wed Mar 13 19:06:29 2002
++++ imlib-1.9.13/Imlib/load.c Thu Sep 16 17:21:01 2004
+@@ -4,6 +4,8 @@
+ #include "Imlib_private.h"
+ #include <setjmp.h>
+
++#define G_MAXINT ((int) 0x7fffffff)
++
+ /* Split the ID - damages input */
+
+ static char *
+@@ -41,13 +43,17 @@
+
+ /*
+ * Make sure we don't wrap on our memory allocations
++ * we check G_MAXINT/4 because rend.c malloc's w * h * bpp
++ * + 3 is safety margin
+ */
+
+ void * _imlib_malloc_image(unsigned int w, unsigned int h)
+ {
+- if( w > 32767 || h > 32767)
+- return NULL;
+- return malloc(w * h * 3);
++ if (w <= 0 || w > 32767 ||
++ h <= 0 || h > 32767 ||
++ h >= (G_MAXINT/4 - 1) / w)
++ return NULL;
++ return malloc(w * h * 3 + 3);
+ }
+
+ #ifdef HAVE_LIBJPEG
+@@ -360,7 +366,9 @@
+ npix = ww * hh;
+ *w = (int)ww;
+ *h = (int)hh;
+- if(ww > 32767 || hh > 32767)
++ if (ww <= 0 || ww > 32767 ||
++ hh <= 0 || hh > 32767 ||
++ hh >= (G_MAXINT/sizeof(uint32)) / ww)
+ {
+ TIFFClose(tif);
+ return NULL;
+@@ -463,7 +471,7 @@
+ }
+ *w = gif->Image.Width;
+ *h = gif->Image.Height;
+- if (*h > 32767 || *w > 32767)
++ if (*h <= 0 || *h > 32767 || *w <= 0 || *w > 32767)
+ {
+ return NULL;
+ }
+@@ -965,7 +973,12 @@
+ comment = 0;
+ quote = 0;
+ context = 0;
++ memset(lookup, 0, sizeof(lookup));
++
+ line = malloc(lsz);
++ if (!line)
++ return NULL;
++
+ while (!done)
+ {
+ pc = c;
+@@ -994,25 +1007,25 @@
+ {
+ /* Header */
+ sscanf(line, "%i %i %i %i", w, h, &ncolors, &cpp);
+- if (ncolors > 32766)
++ if (ncolors <= 0 || ncolors > 32766)
+ {
+ fprintf(stderr, "IMLIB ERROR: XPM files wth colors > 32766 not supported\n");
+ free(line);
+ return NULL;
+ }
+- if (cpp > 5)
++ if (cpp <= 0 || cpp > 5)
+ {
+ fprintf(stderr, "IMLIB ERROR: XPM files with characters per pixel > 5 not supported\n");
+ free(line);
+ return NULL;
+ }
+- if (*w > 32767)
++ if (*w <= 0 || *w > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for file\n");
+ free(line);
+ return NULL;
+ }
+- if (*h > 32767)
++ if (*h <= 0 || *h > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for file\n");
+ free(line);
+@@ -1045,11 +1058,13 @@
+ {
+ int slen;
+ int hascolor, iscolor;
++ int space;
+
+ iscolor = 0;
+ hascolor = 0;
+ tok[0] = 0;
+ col[0] = 0;
++ space = sizeof(col) - 1;
+ s[0] = 0;
+ len = strlen(line);
+ strncpy(cmap[j].str, line, cpp);
+@@ -1072,10 +1087,10 @@
+ {
+ if (k >= len)
+ {
+- if (col[0])
+- strcat(col, " ");
+- if (strlen(col) + strlen(s) < sizeof(col))
+- strcat(col, s);
++ if (col[0] && space > 0)
++ strcat(col, " "), space -= 1;
++ if (slen <= space)
++ strcat(col, s), space -= slen;
+ }
+ if (col[0])
+ {
+@@ -1105,14 +1120,17 @@
+ }
+ }
+ }
+- strcpy(tok, s);
++ if (slen < sizeof(tok));
++ strcpy(tok, s);
+ col[0] = 0;
++ space = sizeof(col) - 1;
+ }
+ else
+ {
+- if (col[0])
+- strcat(col, " ");
+- strcat(col, s);
++ if (col[0] && space > 0)
++ strcat(col, " "), space -=1;
++ if (slen <= space)
++ strcat(col, s), space -= slen;
+ }
+ }
+ }
+@@ -1341,12 +1359,12 @@
+ sscanf(s, "%i %i", w, h);
+ a = *w;
+ b = *h;
+- if (a > 32767)
++ if (a <= 0 || a > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for file\n");
+ return NULL;
+ }
+- if (b > 32767)
++ if (b <= 0 || b > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for file\n");
+ return NULL;
+diff -urN imlib-1.9.13.orig/Imlib/utils.c imlib-1.9.13/Imlib/utils.c
+--- imlib-1.9.13.orig/Imlib/utils.c Mon Mar 4 17:45:28 2002
++++ imlib-1.9.13/Imlib/utils.c Thu Sep 16 17:21:15 2004
+@@ -1496,36 +1496,56 @@
+ context = 0;
+ ptr = NULL;
+ end = NULL;
++ memset(lookup, 0, sizeof(lookup));
+
+ while (!done)
+ {
+ line = data[count++];
++ if (!line)
++ break;
++ line = strdup(line);
++ if (!line)
++ break;
++ len = strlen(line);
++ for (i = 0; i < len; ++i)
++ {
++ c = line[i];
++ if (c < 32)
++ line[i] = 32;
++ else if (c > 127)
++ line[i] = 127;
++ }
++
+ if (context == 0)
+ {
+ /* Header */
+ sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
+- if (ncolors > 32766)
++ if (ncolors <= 0 || ncolors > 32766)
+ {
+ fprintf(stderr, "IMLIB ERROR: XPM data wth colors > 32766 not supported\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (cpp > 5)
++ if (cpp <= 0 || cpp > 5)
+ {
+ fprintf(stderr, "IMLIB ERROR: XPM data with characters per pixel > 5 not supported\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (w > 32767)
++ if (w <= 0 || w > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for data\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (h > 32767)
++ if (h <= 0 || h > 32767)
+ {
+ fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for data\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+ cmap = malloc(sizeof(struct _cmap) * ncolors);
+@@ -1533,6 +1553,7 @@
+ if (!cmap)
+ {
+ free(im);
++ free(line);
+ return NULL;
+ }
+ im->rgb_width = w;
+@@ -1542,6 +1563,7 @@
+ {
+ free(cmap);
+ free(im);
++ free(line);
+ return NULL;
+ }
+ im->alpha_data = NULL;
+@@ -1817,6 +1839,7 @@
+ }
+ if ((ptr) && ((ptr - im->rgb_data) >= w * h * 3))
+ done = 1;
++ free(line);
+ }
+ if (!transp)
+ {
+diff -urN imlib-1.9.13.orig/gdk_imlib/io-gif.c imlib-1.9.13/gdk_imlib/io-gif.c
+--- imlib-1.9.13.orig/gdk_imlib/io-gif.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/io-gif.c Thu Sep 16 16:11:31 2004
+@@ -55,7 +55,7 @@
+ }
+ *w = gif->Image.Width;
+ *h = gif->Image.Height;
+- if(*h > 32767 || *w > 32767)
++ if(*h <= 0 || *h > 32767 || *w <= 0 || *w > 32767)
+ {
+ return NULL;
+ }
+diff -urN imlib-1.9.13.orig/gdk_imlib/io-ppm.c imlib-1.9.13/gdk_imlib/io-ppm.c
+--- imlib-1.9.13.orig/gdk_imlib/io-ppm.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/io-ppm.c Thu Sep 16 16:13:13 2004
+@@ -53,12 +53,12 @@
+ sscanf(s, "%i %i", w, h);
+ a = *w;
+ b = *h;
+- if (a > 32767)
++ if (a <= 0 || a > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
+ return NULL;
+ }
+- if (b > 32767)
++ if (b <= 0 || b > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
+ return NULL;
+diff -urN imlib-1.9.13.orig/gdk_imlib/io-tiff.c imlib-1.9.13/gdk_imlib/io-tiff.c
+--- imlib-1.9.13.orig/gdk_imlib/io-tiff.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/io-tiff.c Thu Sep 16 16:13:57 2004
+@@ -36,7 +36,9 @@
+ npix = ww * hh;
+ *w = (int)ww;
+ *h = (int)hh;
+- if(ww > 32767 || hh > 32767)
++ if (ww <= 0 || ww > 32767 ||
++ hh <= 0 || hh > 32767 ||
++ hh >= (G_MAXINT/sizeof(uint32)) / ww)
+ {
+ TIFFClose(tif);
+ return NULL;
+diff -urN imlib-1.9.13.orig/gdk_imlib/io-xpm.c imlib-1.9.13/gdk_imlib/io-xpm.c
+--- imlib-1.9.13.orig/gdk_imlib/io-xpm.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/io-xpm.c Thu Sep 16 17:08:24 2004
+@@ -40,8 +40,12 @@
+ context = 0;
+ i = j = 0;
+ cmap = NULL;
++ memset(lookup, 0, sizeof(lookup));
+
+ line = malloc(lsz);
++ if (!line)
++ return NULL;
++
+ while (!done)
+ {
+ pc = c;
+@@ -70,25 +74,25 @@
+ {
+ /* Header */
+ sscanf(line, "%i %i %i %i", w, h, &ncolors, &cpp);
+- if (ncolors > 32766)
++ if (ncolors <= 0 || ncolors > 32766)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: XPM files wth colors > 32766 not supported\n");
+ free(line);
+ return NULL;
+ }
+- if (cpp > 5)
++ if (cpp <= 0 || cpp > 5)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: XPM files with characters per pixel > 5 not supported\n");
+ free(line);
+ return NULL;
+ }
+- if (*w > 32767)
++ if (*w <= 0 || *w > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
+ free(line);
+ return NULL;
+ }
+- if (*h > 32767)
++ if (*h <= 0 || *h > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
+ free(line);
+@@ -120,11 +124,13 @@
+ {
+ int slen;
+ int hascolor, iscolor;
++ int space;
+
+ hascolor = 0;
+ iscolor = 0;
+ tok[0] = 0;
+ col[0] = 0;
++ space = sizeof(col) - 1;
+ s[0] = 0;
+ len = strlen(line);
+ strncpy(cmap[j].str, line, cpp);
+@@ -147,10 +153,10 @@
+ {
+ if (k >= len)
+ {
+- if (col[0])
+- strcat(col, " ");
+- if (strlen(col) + strlen(s) < sizeof(col))
+- strcat(col, s);
++ if (col[0] && space > 0)
++ strncat(col, " ", space), space -= 1;
++ if (slen <= space)
++ strcat(col, s), space -= slen;
+ }
+ if (col[0])
+ {
+@@ -180,14 +186,17 @@
+ }
+ }
+ }
+- strcpy(tok, s);
++ if (slen < sizeof(tok))
++ strcpy(tok, s);
+ col[0] = 0;
++ space = sizeof(col) - 1;
+ }
+ else
+ {
+- if (col[0])
+- strcat(col, " ");
+- strcat(col, s);
++ if (col[0] && space > 0)
++ strcat(col, " "), space -= 1;
++ if (slen <= space)
++ strcat(col, s), space -= slen;
+ }
+ }
+ }
+diff -urN imlib-1.9.13.orig/gdk_imlib/misc.c imlib-1.9.13/gdk_imlib/misc.c
+--- imlib-1.9.13.orig/gdk_imlib/misc.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/misc.c Thu Sep 16 16:35:32 2004
+@@ -1355,11 +1355,16 @@
+
+ /*
+ * Make sure we don't wrap on our memory allocations
++ * we check G_MAX_INT/4 because rend.c malloc's w * h * bpp
++ * + 3 is safety margin
+ */
+
+ void *_gdk_malloc_image(unsigned int w, unsigned int h)
+ {
+- if( w > 32767 || h > 32767)
++ if (w <= 0 || w > 32767 ||
++ h <= 0 || h > 32767 ||
++ h >= (G_MAXINT/4 - 1) / w)
+ return NULL;
+- return malloc(w * h * 3);
++ return malloc(w * h * 3 + 3);
+ }
++
+diff -urN imlib-1.9.13.orig/gdk_imlib/utils.c imlib-1.9.13/gdk_imlib/utils.c
+--- imlib-1.9.13.orig/gdk_imlib/utils.c Mon Mar 4 17:26:51 2002
++++ imlib-1.9.13/gdk_imlib/utils.c Thu Sep 16 17:28:35 2004
+@@ -1236,36 +1236,56 @@
+ context = 0;
+ ptr = NULL;
+ end = NULL;
++ memset(lookup, 0, sizeof(lookup));
+
+ while (!done)
+ {
+ line = data[count++];
++ if (!line)
++ break;
++ line = strdup(line);
++ if (!line)
++ break;
++ len = strlen(line);
++ for (i = 0; i < len; ++i)
++ {
++ c = line[i];
++ if (c < 32)
++ line[i] = 32;
++ else if (c > 127)
++ line[i] = 127;
++ }
++
+ if (context == 0)
+ {
+ /* Header */
+ sscanf(line, "%i %i %i %i", &w, &h, &ncolors, &cpp);
+- if (ncolors > 32766)
++ if (ncolors <= 0 || ncolors > 32766)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: XPM data wth colors > 32766 not supported\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (cpp > 5)
++ if (cpp <= 0 || cpp > 5)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: XPM data with characters per pixel > 5 not supported\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (w > 32767)
++ if (w <= 0 || w > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image width > 32767 pixels for data\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+- if (h > 32767)
++ if (h <= 0 || h > 32767)
+ {
+ fprintf(stderr, "gdk_imlib ERROR: Image height > 32767 pixels for data\n");
+ free(im);
++ free(line);
+ return NULL;
+ }
+ cmap = malloc(sizeof(struct _cmap) * ncolors);
+@@ -1273,6 +1293,7 @@
+ if (!cmap)
+ {
+ free(im);
++ free(line);
+ return NULL;
+ }
+ im->rgb_width = w;
+@@ -1282,6 +1303,7 @@
+ {
+ free(cmap);
+ free(im);
++ free(line);
+ return NULL;
+ }
+ im->alpha_data = NULL;
+@@ -1355,7 +1377,7 @@
+ strcpy(col + colptr, " ");
+ colptr++;
+ }
+- if (colptr + ls <= sizeof(col))
++ if (colptr + ls < sizeof(col))
+ {
+ strcpy(col + colptr, s);
+ colptr += ls;
+@@ -1558,6 +1580,7 @@
+ }
+ if ((ptr) && ((ptr - im->rgb_data) >= w * h * 3))
+ done = 1;
++ free(line);
+ }
+ if (!transp)
+ {
diff --git a/media-libs/imlib/imlib-1.9.15-r4.ebuild b/media-libs/imlib/imlib-1.9.15-r4.ebuild
new file mode 100644
index 000000000000..e01eca215528
--- /dev/null
+++ b/media-libs/imlib/imlib-1.9.15-r4.ebuild
@@ -0,0 +1,68 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=4
+inherit autotools eutils multilib-minimal
+
+PVP=(${PV//[-\._]/ })
+DESCRIPTION="Image loading and rendering library"
+HOMEPAGE="http://ftp.acc.umu.se/pub/GNOME/sources/imlib/1.9/"
+SRC_URI="mirror://gnome/sources/${PN}/${PVP[0]}.${PVP[1]}/${P}.tar.bz2
+ mirror://gentoo/gtk-1-for-imlib.m4.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~sh sparc x86 ~x86-fbsd"
+IUSE="doc static-libs"
+
+RDEPEND=">=media-libs/tiff-3.9.7-r1[${MULTILIB_USEDEP}]
+ >=media-libs/giflib-4.1.6-r3[${MULTILIB_USEDEP}]
+ >=media-libs/libpng-1.2.51[${MULTILIB_USEDEP}]
+ >=virtual/jpeg-0-r2:0[${MULTILIB_USEDEP}]
+ >=x11-libs/libICE-1.0.8-r1[${MULTILIB_USEDEP}]
+ >=x11-libs/libSM-1.2.1-r1[${MULTILIB_USEDEP}]
+ >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
+ abi_x86_32? (
+ !app-emulation/emul-linux-x86-gtklibs[-abi_x86_32(-)]
+ !<=app-emulation/emul-linux-x86-gtklibs-20140406
+ )"
+DEPEND="${RDEPEND}"
+
+src_prepare() {
+ # Fix aclocal underquoted definition warnings.
+ # Conditionalize gdk functions for bug 40453.
+ # Fix imlib-config for bug 3425.
+ epatch "${FILESDIR}"/${P}.patch
+ epatch "${FILESDIR}"/${PN}-security.patch #security #72681
+ epatch "${FILESDIR}"/${P}-bpp16-CVE-2007-3568.patch # security #201887
+ epatch "${FILESDIR}"/${P}-fix-rendering.patch #197489
+ epatch "${FILESDIR}"/${P}-asneeded.patch #207638
+ epatch "${FILESDIR}"/${P}-libpng15.patch #357167
+ epatch "${FILESDIR}"/${P}-underlinking-test.patch #367645
+ epatch "${FILESDIR}"/${P}-no-LDFLAGS-in-pc.patch
+
+ mkdir m4 && cp "${WORKDIR}"/gtk-1-for-imlib.m4 m4
+
+ AT_M4DIR="m4" eautoreconf
+}
+
+multilib_src_configure() {
+ ECONF_SOURCE="${S}" econf \
+ --sysconfdir=/etc/imlib \
+ $(use_enable static-libs static) \
+ --disable-gdk \
+ --disable-gtktest
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" install || die
+}
+
+multilib_src_install_all() {
+ dodoc AUTHORS ChangeLog README
+ use doc && dohtml doc/*
+
+ # Punt unused files
+ rm -f "${D}"/usr/lib*/pkgconfig/imlibgdk.pc
+ find "${D}" -name '*.la' -exec rm -f {} +
+}
diff --git a/media-libs/imlib/imlib-1.9.15-r5.ebuild b/media-libs/imlib/imlib-1.9.15-r5.ebuild
new file mode 100644
index 000000000000..786faa8856fe
--- /dev/null
+++ b/media-libs/imlib/imlib-1.9.15-r5.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+inherit autotools multilib-minimal
+
+PVP=(${PV//[-\._]/ })
+DESCRIPTION="Image loading and rendering library"
+HOMEPAGE="http://ftp.acc.umu.se/pub/GNOME/sources/imlib/1.9/"
+SRC_URI="mirror://gnome/sources/${PN}/${PVP[0]}.${PVP[1]}/${P}.tar.bz2
+ mirror://gentoo/gtk-1-for-imlib.m4.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~sh sparc x86 ~x86-fbsd"
+IUSE="doc static-libs"
+
+RDEPEND="
+ >=media-libs/tiff-3.9.7-r1:0[${MULTILIB_USEDEP}]
+ >=media-libs/giflib-5.1:0=[${MULTILIB_USEDEP}]
+ >=media-libs/libpng-1.2.51:0=[${MULTILIB_USEDEP}]
+ >=virtual/jpeg-0-r2:0[${MULTILIB_USEDEP}]
+ >=x11-libs/libICE-1.0.8-r1[${MULTILIB_USEDEP}]
+ >=x11-libs/libSM-1.2.1-r1[${MULTILIB_USEDEP}]
+ >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
+"
+DEPEND="${RDEPEND}"
+
+src_prepare() {
+ default
+
+ # Fix aclocal underquoted definition warnings.
+ # Conditionalize gdk functions for bug 40453.
+ # Fix imlib-config for bug 3425.
+ eapply "${FILESDIR}"/${P}.patch
+ eapply "${FILESDIR}"/${PN}-security.patch #security #72681
+ eapply "${FILESDIR}"/${P}-bpp16-CVE-2007-3568.patch # security #201887
+ eapply "${FILESDIR}"/${P}-fix-rendering.patch #197489
+ eapply "${FILESDIR}"/${P}-asneeded.patch #207638
+ eapply "${FILESDIR}"/${P}-libpng15.patch #357167
+ eapply "${FILESDIR}"/${P}-underlinking-test.patch #367645
+ eapply "${FILESDIR}"/${P}-no-LDFLAGS-in-pc.patch
+ eapply "${FILESDIR}"/${P}-giflib51-{1,2}.patch #538976
+
+ mkdir m4 && cp "${WORKDIR}"/gtk-1-for-imlib.m4 m4
+
+ AT_M4DIR="m4" eautoreconf
+}
+
+multilib_src_configure() {
+ ECONF_SOURCE="${S}" econf \
+ --sysconfdir=/etc/imlib \
+ $(use_enable static-libs static) \
+ --disable-gdk \
+ --disable-gtktest
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" install
+ # fix target=@gdk-target@ in pkgconfig, bug #499268
+ sed -e '/^target=/d' \
+ -i "${ED}"usr/$(get_libdir)/pkgconfig/imlib.pc || die
+}
+
+multilib_src_install_all() {
+ einstalldocs
+ use doc && dohtml doc/*
+
+ # Punt unused files
+ rm -f "${D}"/usr/lib*/pkgconfig/imlibgdk.pc
+ find "${D}" -name '*.la' -exec rm -f {} + || die
+}
diff --git a/media-libs/imlib/metadata.xml b/media-libs/imlib/metadata.xml
new file mode 100644
index 000000000000..19bf1be2581e
--- /dev/null
+++ b/media-libs/imlib/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>graphics@gentoo.org</email>
+ <name>Gentoo Graphics Project</name>
+</maintainer>
+</pkgmetadata>