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.
This commit is contained in:
parent
5c10d2ded7
commit
1bb0124b77
1
NEWS
1
NEWS
|
@ -41,6 +41,7 @@ ver 0.15 - (200?/??/??)
|
||||||
* playlist: recalculate the queued song after random is toggled
|
* playlist: recalculate the queued song after random is toggled
|
||||||
* playlist: don't unpause on delete
|
* playlist: don't unpause on delete
|
||||||
* daemon: ignore "user" setting if already running as that user
|
* 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)
|
ver 0.14.2 (2009/02/13)
|
||||||
|
|
|
@ -448,14 +448,15 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
int listen_fd = GPOINTER_TO_INT(data), fd;
|
int listen_fd = GPOINTER_TO_INT(data), fd;
|
||||||
struct sockaddr sockAddr;
|
struct sockaddr_storage sa;
|
||||||
socklen_t socklen = sizeof(sockAddr);
|
socklen_t sa_length = sizeof(sa);
|
||||||
|
|
||||||
fd = accept(listen_fd, &sockAddr, &socklen);
|
fd = accept(listen_fd, (struct sockaddr*)&sa, &sa_length);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
set_nonblocking(fd);
|
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) {
|
} else if (fd < 0 && errno != EINTR) {
|
||||||
g_warning("Problems accept()'ing");
|
g_warning("Problems accept()'ing");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue