summaryrefslogtreecommitdiff
path: root/dbus/dbus-nonce.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-14 12:23:09 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-05-14 14:30:30 +0100
commitbcdead0fd4642a5e8985981c1583d40ff779299a (patch)
tree2285d47c351a1a07bb22f060293f641b711d5785 /dbus/dbus-nonce.c
parentf385324d8b03eab13f3e618ce9a0018977c9a7cb (diff)
downloaddbus-bcdead0fd4642a5e8985981c1583d40ff779299a.tar.gz
Fail to generate random bytes instead of falling back to rand()
This is more robust against broken setups where we run out of memory or cannot read /dev/urandom. 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-nonce.c')
-rw-r--r--dbus/dbus-nonce.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c
index e5685e16..3c0f6f37 100644
--- a/dbus/dbus-nonce.c
+++ b/dbus/dbus-nonce.c
@@ -186,9 +186,8 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error)
return FALSE;
}
- if (!_dbus_generate_random_bytes (&nonce, 16))
+ if (!_dbus_generate_random_bytes (&nonce, 16, error))
{
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (&nonce);
return FALSE;
}
@@ -272,9 +271,8 @@ do_noncefile_create (DBusNonceFile *noncefile,
goto on_error;
}
- if (!_dbus_generate_random_ascii (&randomStr, 8))
+ if (!_dbus_generate_random_ascii (&randomStr, 8, error))
{
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto on_error;
}