Better handling of inet_ntop() failures (which should not happen in practice, since we filter on address family, but let's be cautious).
This commit is contained in:
parent
0d974e1c9c
commit
16d0864818
2 changed files with 6 additions and 2 deletions
|
|
@ -70,7 +70,9 @@ host_connect(const char *host, const char *port, int verbose)
|
|||
addr = NULL;
|
||||
}
|
||||
if (addr != NULL) {
|
||||
inet_ntop(p->ai_family, addr, tmp, sizeof tmp);
|
||||
if (!inet_ntop(p->ai_family, addr, tmp, sizeof tmp)) {
|
||||
strcpy(tmp, "<invalid>");
|
||||
}
|
||||
} else {
|
||||
sprintf(tmp, "<unknown family: %d>",
|
||||
(int)sa->sa_family);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ host_bind(const char *host, const char *port, int verbose)
|
|||
sa_len = p->ai_addrlen;
|
||||
}
|
||||
if (addr != NULL) {
|
||||
inet_ntop(p->ai_family, addr, tmp, sizeof tmp);
|
||||
if (!inet_ntop(p->ai_family, addr, tmp, sizeof tmp)) {
|
||||
strcpy(tmp, "<invalid>");
|
||||
}
|
||||
} else {
|
||||
sprintf(tmp, "<unknown family: %d>",
|
||||
(int)sa->sa_family);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue