aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-28 15:20:35 +0100
committerMax Kellermann <max@duempel.org>2009-02-28 15:20:35 +0100
commit1bb0124b77a21ab560c1b0d0a67259b6979648d7 (patch)
tree404b8b0553896305079f90b716217e12ccafb7cc
parent5c10d2ded7e14a5c155115e27ced5178546f0d05 (diff)
downloadmpd-1bb0124b77a21ab560c1b0d0a67259b6979648d7.tar.gz
mpd-1bb0124b77a21ab560c1b0d0a67259b6979648d7.tar.xz
mpd-1bb0124b77a21ab560c1b0d0a67259b6979648d7.zip
listen: allocate sockaddr_storage struct for accept()
The generic sockaddr struct is too small for some addresses. For accept(), we have to allocate a sockaddr_storage struct on the stack, which is large enough for all addresses.
Diffstat (limited to '')
-rw-r--r--NEWS1
-rw-r--r--src/listen.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 7bdae31e4..5ea4f2d4c 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ ver 0.15 - (200?/??/??)
* playlist: recalculate the queued song after random is toggled
* playlist: don't unpause on delete
* daemon: ignore "user" setting if already running as that user
+* listen: fix broken client IP addresses in log
ver 0.14.2 (2009/02/13)
diff --git a/src/listen.c b/src/listen.c
index c7f66e887..ff4d5cccd 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -448,14 +448,15 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source,
gpointer data)
{
int listen_fd = GPOINTER_TO_INT(data), fd;
- struct sockaddr sockAddr;
- socklen_t socklen = sizeof(sockAddr);
+ struct sockaddr_storage sa;
+ socklen_t sa_length = sizeof(sa);
- fd = accept(listen_fd, &sockAddr, &socklen);
+ fd = accept(listen_fd, (struct sockaddr*)&sa, &sa_length);
if (fd >= 0) {
set_nonblocking(fd);
- client_new(fd, &sockAddr, socklen, get_remote_uid(fd));
+ client_new(fd, (struct sockaddr*)&sa, sa_length,
+ get_remote_uid(fd));
} else if (fd < 0 && errno != EINTR) {
g_warning("Problems accept()'ing");
}