host: Properly initialize struct sockaddr_in[6] when parsing strings
Otherwise struct members like sin6_flowinfo or sin6_scope_id might be set to bogus values.
This commit is contained in:
committed by
Andreas Steffen
parent
b3393c88c1
commit
ed0efaef4c
@@ -381,6 +381,7 @@ host_t *host_create_from_string_and_family(char *string, int family,
|
|||||||
}
|
}
|
||||||
/* FALL */
|
/* FALL */
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
|
memset(&addr.v6, 0, sizeof(addr.v6));
|
||||||
if (inet_pton(AF_INET6, string, &addr.v6.sin6_addr) != 1)
|
if (inet_pton(AF_INET6, string, &addr.v6.sin6_addr) != 1)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -394,6 +395,7 @@ host_t *host_create_from_string_and_family(char *string, int family,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
af_inet:
|
af_inet:
|
||||||
|
memset(&addr.v4, 0, sizeof(addr.v4));
|
||||||
if (inet_pton(AF_INET, string, &addr.v4.sin_addr) != 1)
|
if (inet_pton(AF_INET, string, &addr.v4.sin_addr) != 1)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user