]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Ensure DBusError is set if _dbus_read_nonce() fail
authorChengwei Yang <chengwei.yang@intel.com>
Fri, 6 Dec 2013 02:53:28 +0000 (10:53 +0800)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 6 Jan 2014 16:05:45 +0000 (16:05 +0000)
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>
dbus/dbus-nonce.c

index ef037ef9428343796c5c329c3e75ee8cbb901216..37f30f003df8b4c8a2421288d0a45d0007a49eaa 100644 (file)
@@ -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)