summaryrefslogtreecommitdiff
path: root/dbus/dbus-uuidgen.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-12 11:35:04 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-14 14:30:30 +0100
commitf385324d8b03eab13f3e618ce9a0018977c9a7cb (patch)
tree84528b88cc370981440f06a6d4592e745c0e2b04 /dbus/dbus-uuidgen.c
parent49646211f3c8dcdc3728f4059c61c05ef4df857c (diff)
downloaddbus-f385324d8b03eab13f3e618ce9a0018977c9a7cb.tar.gz
Make UUID generation failable
Previously, this would always succeed, but might use weak random numbers in rare failure cases. I don't think these UUIDs are security-sensitive, but if they're generated by a PRNG as weak as rand() (<= 32 bits of entropy), we certainly can't claim that they're universally unique. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> [smcv: document @error] Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'dbus/dbus-uuidgen.c')
-rw-r--r--dbus/dbus-uuidgen.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/dbus/dbus-uuidgen.c b/dbus/dbus-uuidgen.c
index 6d7c0aec..b4041633 100644
--- a/dbus/dbus-uuidgen.c
+++ b/dbus/dbus-uuidgen.c
@@ -111,20 +111,20 @@ dbus_internal_do_not_use_get_uuid (const char *filename,
}
/**
- * For use by the dbus-uuidgen binary ONLY, do not call this.
- * We can and will change this function without modifying
- * the libdbus soname.
- *
* @param uuid_p out param to return the uuid
- * @returns #FALSE if no memory
+ * @param error location to store reason for failure
+ * @returns #TRUE on success
*/
dbus_bool_t
-dbus_internal_do_not_use_create_uuid (char **uuid_p)
+_dbus_create_uuid (char **uuid_p,
+ DBusError *error)
{
DBusGUID uuid;
- _dbus_generate_uuid (&uuid);
- return return_uuid (&uuid, uuid_p, NULL);
+ if (!_dbus_generate_uuid (&uuid, error))
+ return FALSE;
+
+ return return_uuid (&uuid, uuid_p, error);
}
/** @} */