From 762ec414441da106777c09c78ad02105f84d948b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 7 Oct 2016 19:05:40 +0100 Subject: [PATCH 03/13] dbus-nonce: print sockets correctly Since early 2015, a DBusSocket has been a struct containing either an int or a pointer-sized Windows SOCKET. Print them with "%" DBUS_SOCKET_FORMAT and _dbus_socket_printable(). Bug found by adding more _DBUS_GNUC_PRINTF attributes. Signed-off-by: Simon McVittie --- dbus/dbus-nonce.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 3c0f6f3..bc3286c 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -64,7 +64,7 @@ do_check_nonce (DBusSocket fd, const DBusString *nonce, DBusError *error) _dbus_sleep_milliseconds (100); else if (n==-1) { - dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd ); + dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%" DBUS_SOCKET_FORMAT ")", _dbus_socket_printable (fd)); _dbus_string_free (&p); _dbus_string_free (&buffer); return FALSE; @@ -73,7 +73,7 @@ do_check_nonce (DBusSocket fd, const DBusString *nonce, DBusError *error) { _dbus_string_free (&p); _dbus_string_free (&buffer); - dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%d)", fd ); + dbus_set_error (error, DBUS_ERROR_IO_ERROR, "Could not read nonce from socket (fd=%" DBUS_SOCKET_FORMAT ")", _dbus_socket_printable (fd)); return FALSE; } else @@ -91,7 +91,7 @@ do_check_nonce (DBusSocket fd, const DBusString *nonce, DBusError *error) result = _dbus_string_equal_len (&buffer, nonce, 16); if (!result) - dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "Nonces do not match, access denied (fd=%d)", fd ); + dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "Nonces do not match, access denied (fd=%" DBUS_SOCKET_FORMAT ")", _dbus_socket_printable (fd)); _dbus_string_free (&p); _dbus_string_free (&buffer); @@ -245,8 +245,9 @@ _dbus_send_nonce (DBusSocket fd, { dbus_set_error (error, _dbus_error_from_system_errno (), - "Failed to send nonce (fd=%d): %s", - fd, _dbus_strerror_from_errno ()); + "Failed to send nonce (fd=%" DBUS_SOCKET_FORMAT "): %s", + _dbus_socket_printable (fd), + _dbus_strerror_from_errno ()); return FALSE; } -- 2.9.3