1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

The tcp_wrappers function `fromhost()' can fail. In such

cases, the `struct sockaddr' will not be allocated.

Reported by:	nectar
MFC after:	2 days
This commit is contained in:
Hajimu UMEMOTO 2003-02-13 17:08:23 +00:00
parent d38a104b75
commit 6431ecd0a1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110802

View File

@ -304,6 +304,20 @@ getvalue(const char *arg, int *value, const char *whine)
return 0; /* success */ return 0; /* success */
} }
static sa_family_t
whichaf(struct request_info *req)
{
struct sockaddr *sa;
sa = (struct sockaddr *)req->client->sin;
if (sa == NULL)
return AF_UNSPEC;
if (sa->sa_family == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)sa)->sin6_addr))
return AF_INET;
return sa->sa_family;
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -744,7 +758,7 @@ main(int argc, char **argv)
syslog(deny_severity, syslog(deny_severity,
"refused connection from %.500s, service %s (%s%s)", "refused connection from %.500s, service %s (%s%s)",
eval_client(&req), service, sep->se_proto, eval_client(&req), service, sep->se_proto,
(((struct sockaddr *)req.client->sin)->sa_family == AF_INET6 && !IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)req.client->sin)->sin6_addr)) ? "6" : ""); (whichaf(&req) == AF_INET6) ? "6" : "");
if (sep->se_socktype != SOCK_STREAM) if (sep->se_socktype != SOCK_STREAM)
recv(ctrl, buf, sizeof (buf), 0); recv(ctrl, buf, sizeof (buf), 0);
if (dofork) { if (dofork) {
@ -756,7 +770,7 @@ main(int argc, char **argv)
syslog(allow_severity, syslog(allow_severity,
"connection from %.500s, service %s (%s%s)", "connection from %.500s, service %s (%s%s)",
eval_client(&req), service, sep->se_proto, eval_client(&req), service, sep->se_proto,
(((struct sockaddr *)req.client->sin)->sa_family == AF_INET6 && !IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)req.client->sin)->sin6_addr)) ? "6" : ""); (whichaf(&req) == AF_INET6) ? "6" : "");
} }
} }
if (sep->se_bi) { if (sep->se_bi) {