mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 05:18:00 +02:00
sysdeps: Avoid passing possibly null port-number string to printf %s
gcc 14 detects that port can be NULL here, which is technically invalid to pass to printf (although many implementations print it as "(null)"). Becuase we're using getaddrinfo(), we treat a NULL service (port number string) as a request to listen on "port 0", meaning we ask the kernel to assign an arbitrary nonzero port for us; when printing addresses in error messages, treating that as port 0 seems reasonable. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
408fc1793b
commit
d8eaa77f43
2 changed files with 6 additions and 6 deletions
|
|
@ -1652,7 +1652,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
dbus_set_error (error,
|
||||
_dbus_error_from_gai (res, errno),
|
||||
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
|
||||
host ? host : "*", port, gai_strerror(res), res);
|
||||
host ? host : "*", port ? port : "0", gai_strerror(res), res);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
|
@ -1673,7 +1673,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr))==-1)
|
||||
{
|
||||
_dbus_warn ("Failed to set socket option \"%s:%s\": %s",
|
||||
host ? host : "*", port, _dbus_strerror (errno));
|
||||
host ? host : "*", port ? port : "0", _dbus_strerror (errno));
|
||||
}
|
||||
|
||||
/* Nagle's algorithm imposes a huge delay on the initial messages
|
||||
|
|
@ -1682,7 +1682,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
if (setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &tcp_nodelay_on, sizeof (tcp_nodelay_on)) == -1)
|
||||
{
|
||||
_dbus_warn ("Failed to set TCP_NODELAY socket option \"%s:%s\": %s",
|
||||
host ? host : "*", port, _dbus_strerror (errno));
|
||||
host ? host : "*", port ? port : "0", _dbus_strerror (errno));
|
||||
}
|
||||
|
||||
if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0)
|
||||
|
|
@ -1783,7 +1783,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
saved_errno = errno;
|
||||
dbus_set_error (error, _dbus_error_from_errno (saved_errno),
|
||||
"Failed to retrieve socket name for \"%s:%s\": %s",
|
||||
host ? host : "*", port, _dbus_strerror (saved_errno));
|
||||
host ? host : "*", port ? port : "0", _dbus_strerror (saved_errno));
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
|
@ -1794,7 +1794,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
saved_errno = errno;
|
||||
dbus_set_error (error, _dbus_error_from_gai (res, saved_errno),
|
||||
"Failed to resolve port \"%s:%s\": %s (%d)",
|
||||
host ? host : "*", port, gai_strerror(res), res);
|
||||
host ? host : "*", port ? port : "0", gai_strerror(res), res);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ _dbus_combine_tcp_errors (DBusList **sources,
|
|||
name = DBUS_ERROR_FAILED;
|
||||
|
||||
dbus_set_error (dest, name, "%s to \"%s\":%s (%s)",
|
||||
summary, host ? host : "*", port,
|
||||
summary, host ? host : "*", port ? port : "0",
|
||||
_dbus_string_get_const_data (&message));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue