From a230696f24c4cbfec6418e95635670162a78bf1a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 20 Nov 2013 15:33:45 +0800 Subject: [PATCH] _dbus_append_address_from_socket(): escape value got from socket fd So far, this bug can be triggered in systemd environment, if the configured ListenStream for dbus.socket has characters must be escaped first. Then we'll get an error like "In D-Bus address, character '%c' should have been escaped\n" Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46013 --- dbus/dbus-sysdeps-unix.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 0708004..eed21c2 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4059,26 +4059,30 @@ _dbus_append_address_from_socket (int fd, case AF_UNIX: if (socket.un.sun_path[0]=='\0') { - if (_dbus_string_append_printf (address, "unix:abstract=%s", &(socket.un.sun_path[1]))) + if (_dbus_string_append_printf (address, "unix:abstract=%s", + dbus_address_escape_value (&(socket.un.sun_path[1])))) return TRUE; } else { - if (_dbus_string_append_printf (address, "unix:path=%s", socket.un.sun_path)) + if (_dbus_string_append_printf (address, "unix:path=%s", + dbus_address_escape_value (socket.un.sun_path))) return TRUE; } break; case AF_INET: if (inet_ntop (AF_INET, &socket.ipv4.sin_addr, hostip, sizeof (hostip))) if (_dbus_string_append_printf (address, "tcp:family=ipv4,host=%s,port=%u", - hostip, ntohs (socket.ipv4.sin_port))) + dbus_address_escape_value (hostip), + ntohs (socket.ipv4.sin_port))) return TRUE; break; #ifdef AF_INET6 case AF_INET6: if (inet_ntop (AF_INET6, &socket.ipv6.sin6_addr, hostip, sizeof (hostip))) if (_dbus_string_append_printf (address, "tcp:family=ipv6,host=%s,port=%u", - hostip, ntohs (socket.ipv6.sin6_port))) + dbus_address_escape_value (hostip), + ntohs (socket.ipv6.sin6_port))) return TRUE; break; #endif -- 1.7.9.5