mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
Fix IPv6 memory corruption crash on FreeBSD.
getsockname() into addrin6 instead of addrin when ipv6 is requested.
This commit is contained in:
parent
485ebd1a20
commit
15eda67214
15
darkhttpd.c
15
darkhttpd.c
@ -889,6 +889,10 @@ static void init_sockin(void) {
|
||||
err(1, "bind(port %u)", bindport);
|
||||
|
||||
addrin_len = sizeof(addrin6);
|
||||
if (getsockname(sockin, (struct sockaddr *)&addrin6, &addrin_len) == -1)
|
||||
err(1, "getsockname()");
|
||||
printf("listening on: http://[%s]:%u/\n",
|
||||
get_address_text(&addrin6.sin6_addr), bindport);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@ -897,20 +901,9 @@ static void init_sockin(void) {
|
||||
if (bind(sockin, (struct sockaddr *)&addrin,
|
||||
sizeof(struct sockaddr_in)) == -1)
|
||||
err(1, "bind(port %u)", bindport);
|
||||
|
||||
addrin_len = sizeof(addrin);
|
||||
}
|
||||
|
||||
if (getsockname(sockin, (struct sockaddr *)&addrin, &addrin_len) == -1)
|
||||
err(1, "getsockname()");
|
||||
|
||||
#ifdef HAVE_INET6
|
||||
if (inet6) {
|
||||
printf("listening on: http://[%s]:%u/\n",
|
||||
get_address_text(&addrin6.sin6_addr), bindport);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
printf("listening on: http://%s:%u/\n",
|
||||
get_address_text(&addrin.sin_addr), bindport);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user