[gdk-pixbuf/wip/hadess/split-loaders: 3/3] core: Add gdk_pixbuf_init_modules() for applications



commit 7e9c129ee614f9e082ea5350f8870a724ad33499
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Aug 2 11:25:11 2017 +0100

    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

 gdk-pixbuf/gdk-pixbuf-io.c | 28 ++++++++++++++++++++++++++++
 gdk-pixbuf/gdk-pixbuf-io.h |  3 +++
 2 files changed, 31 insertions(+)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 83118da82..b0b3e21ff 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -551,6 +551,34 @@ gdk_pixbuf_io_init_modules (const char *filename)
 #endif
 }
 
+/**
+ * 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.
+ */
+void
+gdk_pixbuf_init_modules (const char *path)
+{
+       g_autofree char *filename = NULL;
+
+       g_return_if_fail (path != NULL);
+       filename = g_build_filename (path, "loaders.cache", NULL);
+       gdk_pixbuf_io_init_modules (filename);
+}
+
 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..04307f226 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.h
+++ b/gdk-pixbuf/gdk-pixbuf-io.h
@@ -41,6 +41,9 @@ G_BEGIN_DECLS
 
 typedef struct _GdkPixbufFormat GdkPixbufFormat;
 
+GDK_PIXBUF_AVAILABLE_IN_2_40
+void gdk_pixbuf_init_modules (const char *path);
+
 GDK_PIXBUF_AVAILABLE_IN_ALL
 GType gdk_pixbuf_format_get_type (void) G_GNUC_CONST;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]