mirror of
https://frontier.innolan.net/rainlance/c-ares.git
synced 2026-09-24 09:14:08 +00:00
ares_getnameinfo: Validate socket address family and length.
Validate socket address family and that the socket address length is appropriate for the specified family. Failure is reported with ARES_EBADFAMILY in callback.
This commit is contained in:
+6
-4
@@ -99,20 +99,22 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
struct nameinfo_query *niquery;
|
||||
unsigned int port = 0;
|
||||
|
||||
/* Verify the buffer size */
|
||||
if (salen == sizeof(struct sockaddr_in))
|
||||
/* Validate socket address family and length */
|
||||
if ((sa->sa_family == AF_INET) &&
|
||||
(salen == sizeof(struct sockaddr_in)))
|
||||
{
|
||||
addr = (struct sockaddr_in *)sa;
|
||||
port = addr->sin_port;
|
||||
}
|
||||
else if (salen == sizeof(struct sockaddr_in6))
|
||||
else if ((sa->sa_family == AF_INET6) &&
|
||||
(salen == sizeof(struct sockaddr_in6)))
|
||||
{
|
||||
addr6 = (struct sockaddr_in6 *)sa;
|
||||
port = addr6->sin6_port;
|
||||
}
|
||||
else
|
||||
{
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL, NULL);
|
||||
callback(arg, ARES_EBADFAMILY, 0, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user