From 749d5998c29299c2a40c38d461672b5b41e81092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Sat, 26 Nov 2016 14:05:07 +0100 Subject: [PATCH] Move udisks_string_wipe_and_free to a better place --- src/udisksdaemon.c | 1 + src/udisksdaemonutil.c | 16 ++++++++++++++++ src/udisksdaemonutil.h | 2 ++ src/udisksspawnedjob.c | 9 --------- src/udisksspawnedjob.h | 2 -- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/udisksdaemon.c b/src/udisksdaemon.c index 7a3f4a7..3e1e60b 100644 --- a/src/udisksdaemon.c +++ b/src/udisksdaemon.c @@ -23,6 +23,7 @@ #include "udiskslogging.h" #include "udisksdaemon.h" +#include "udisksdaemonutil.h" #include "udisksprovider.h" #include "udiskslinuxprovider.h" #include "udisksmountmonitor.h" diff --git a/src/udisksdaemonutil.c b/src/udisksdaemonutil.c index af8b0e7..b2772a1 100644 --- a/src/udisksdaemonutil.c +++ b/src/udisksdaemonutil.c @@ -56,6 +56,22 @@ * Various utility routines. */ + +/** + * udisks_string_wipe_and_free: + * @string: A string with potentially unsafe content or %NULL. + * + * Wipes the buffer and frees the string. + */ +void udisks_string_wipe_and_free (GString *string) +{ + if (string != NULL) + { + memset (string->str, '\0', string->len); + g_string_free (string, TRUE); + } +} + /** * udisks_variant_lookup_binary: * @dict: A dictionary #GVariant. diff --git a/src/udisksdaemonutil.h b/src/udisksdaemonutil.h index 9b3a501..c047e6c 100644 --- a/src/udisksdaemonutil.h +++ b/src/udisksdaemonutil.h @@ -32,6 +32,8 @@ gboolean udisks_variant_lookup_binary (GVariant *dict, gboolean udisks_variant_get_binary (GVariant *variant, GString **contents); +void udisks_string_wipe_and_free (GString *str); + gchar *udisks_decode_udev_string (const gchar *str); void udisks_safe_append_to_object_path (GString *str, diff --git a/src/udisksspawnedjob.c b/src/udisksspawnedjob.c index 9a5ffbd..e289c0b 100644 --- a/src/udisksspawnedjob.c +++ b/src/udisksspawnedjob.c @@ -1008,15 +1008,6 @@ udisks_spawned_job_release_resources (UDisksSpawnedJob *job) /* manage strings with potentially unsafe content */ -void udisks_string_wipe_and_free(GString* string) -{ - if (string != NULL) - { - memset (string->str, '\0', string->len); - g_string_free(string, TRUE); - } -} - static gpointer autowipe_buffer_copy (gpointer data) { diff --git a/src/udisksspawnedjob.h b/src/udisksspawnedjob.h index e239e39..394e88e 100644 --- a/src/udisksspawnedjob.h +++ b/src/udisksspawnedjob.h @@ -38,8 +38,6 @@ UDisksSpawnedJob *udisks_spawned_job_new (const gchar *command_li GCancellable *cancellable); const gchar *udisks_spawned_job_get_command_line (UDisksSpawnedJob *job); -void udisks_string_wipe_and_free(GString*); - G_END_DECLS #endif /* __UDISKS_SPAWNED_JOB_H__ */ -- 2.10.2