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



commit 323016232fc173cb75b7443f5610e1b293353a14
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 | 31 +++++++++++++++++++++++++++++++
 gdk-pixbuf/gdk-pixbuf-io.h |  4 ++++
 2 files changed, 35 insertions(+)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 5d43e766d..f9b090e5b 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -555,6 +555,37 @@ 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)
+{
+       g_autofree char *filename = NULL;
+
+       g_return_val_if_fail (path != NULL, FALSE);
+       filename = g_build_filename (path, "loaders.cache", NULL);
+       return gdk_pixbuf_io_init_modules (filename, error);
+}
+
 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;
 


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