diff options
author | Chengwei Yang <chengwei.yang@intel.com> | 2013-12-06 10:53:28 +0800 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-06 16:05:45 +0000 |
commit | 15a5b2637c73d8f6d30acf1517b00182f215eb35 (patch) | |
tree | d245cf72d14390d1d4a01d045b6696ddb4a144c7 | |
parent | f4618906b0dce251cdc3125b60239f7dd0df7183 (diff) | |
download | dbus-15a5b2637c73d8f6d30acf1517b00182f215eb35.tar.gz |
Ensure DBusError is set if _dbus_read_nonce() fail
In _dbus_send_nonce() which call in _dbus_read_nonce() and assert on an
error is set if _dbus_read_nonce() fail. However, in _dbus_read_nonce(),
it may fail on fopen() and left error is unset. This will crash us if
assertions hasn't been disabled.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72298
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | dbus/dbus-nonce.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index ef037ef9..37f30f00 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -113,7 +113,15 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) fp = fopen (_dbus_string_get_const_data (fname), "rb"); if (!fp) - return FALSE; + { + dbus_set_error (error, + _dbus_error_from_system_errno (), + "Failed to open %s for read: %s", + _dbus_string_get_const_data (fname), + _dbus_strerror_from_errno ()); + return FALSE; + } + nread = fread (buffer, 1, sizeof buffer - 1, fp); fclose (fp); if (!nread) |