summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-08-02 11:25:11 +0100
committerEmmanuele Bassi <ebassi@gmail.com>2019-02-28 16:27:46 +0000
commitfd1376b799e411f983ab6faa00b066a8007ad9a1 (patch)
tree177bfd23eb8b2f2deda3984c98a3bfc78f2fa696
parent92a59c80b3d535c358f9caa74c2b1d5038575971 (diff)
downloadgdk-pixbuf-fd1376b799e411f983ab6faa00b066a8007ad9a1.tar.gz
core: Add gdk_pixbuf_init_modules() for applications
gdk_pixbuf_init_modules() should be used by applications which want to have gdk-pixbuf loader modules install in a separate path, usually in the application's library directory. https://bugzilla.gnome.org/show_bug.cgi?id=786035
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c34
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.h4
2 files changed, 38 insertions, 0 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 820a9b887..12dcbe71b 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -555,6 +555,40 @@ gdk_pixbuf_io_init_modules (const char *filename,
return TRUE;
}
+/**
+ * gdk_pixbuf_init_modules:
+ * @path: Path to directory where the loaders.cache is installed
+ *
+ * Initalizes the gdk-pixbuf loader modules referenced by the loaders.cache
+ * file present inside that directory.
+ *
+ * This is to be used by applications that want to ship certain loaders
+ * in a different location from the system ones.
+ *
+ * This is needed when the OS or runtime ships a minimal number of loaders
+ * so as to reduce the potential attack surface of carefully crafted image
+ * files, especially for uncommon file types. Applications that require
+ * broader image file types coverage, such as image viewers, would be
+ * expected to ship the gdk-pixbuf modules in a separate location, bundled
+ * with the application in a separate directory from the OS or runtime-
+ * provided modules.
+ *
+ * Since: 2.40
+ */
+gboolean
+gdk_pixbuf_init_modules (const char *path,
+ GError **error)
+{
+ char *filename;
+ gboolean ret;
+
+ g_return_val_if_fail (path != NULL, FALSE);
+ filename = g_build_filename (path, "loaders.cache", NULL);
+ ret = gdk_pixbuf_io_init_modules (filename, error);
+ g_free (filename);
+ return ret;
+}
+
static void
gdk_pixbuf_io_init_builtin (void)
{
diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h
index 88e21b563..66074bc69 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.h
+++ b/gdk-pixbuf/gdk-pixbuf-io.h
@@ -41,6 +41,10 @@ G_BEGIN_DECLS
typedef struct _GdkPixbufFormat GdkPixbufFormat;
+GDK_PIXBUF_AVAILABLE_IN_2_40
+gboolean gdk_pixbuf_init_modules (const char *path,
+ GError **error);
+
GDK_PIXBUF_AVAILABLE_IN_ALL
GType gdk_pixbuf_format_get_type (void) G_GNUC_CONST;