~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
INADDR_NONE is nonstandard. Use (in_addr_t)(-1) instead.
[sgt/putty]
/
unix
/
uxnet.c
diff --git
a/unix/uxnet.c
b/unix/uxnet.c
index
f1ef98b
..
0894221
100644
(file)
--- a/
unix/uxnet.c
+++ b/
unix/uxnet.c
@@
-145,14
+145,16
@@
SockAddr sk_namelookup(const char *host, char **canonicalname, int address_famil
#ifndef NO_IPV6
hints.ai_flags = AI_CANONNAME;
#ifndef NO_IPV6
hints.ai_flags = AI_CANONNAME;
- hints.ai_family = address_family;
- hints.ai_socktype = 0;
+ hints.ai_family = (address_family == ADDRTYPE_IPV4 ? AF_INET :
+ address_family == ADDRTYPE_IPV6 ? AF_INET6 :
+ AF_UNSPEC);
+ hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_addrlen = 0;
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
hints.ai_next = NULL;
hints.ai_protocol = 0;
hints.ai_addrlen = 0;
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
hints.ai_next = NULL;
- err = getaddrinfo(host, NULL,
NULL
, &ret->ai);
+ err = getaddrinfo(host, NULL,
&hints
, &ret->ai);
if (err != 0) {
ret->error = gai_strerror(err);
return ret;
if (err != 0) {
ret->error = gai_strerror(err);
return ret;
@@
-164,7
+166,7
@@
SockAddr sk_namelookup(const char *host, char **canonicalname, int address_famil
else
strncat(realhost, host, sizeof(realhost) - 1);
#else
else
strncat(realhost, host, sizeof(realhost) - 1);
#else
- if ((a = inet_addr(host)) == (unsigned long)
INADDR_NONE
) {
+ if ((a = inet_addr(host)) == (unsigned long)
(in_addr_t)(-1)
) {
/*
* Otherwise use the IPv4-only gethostbyname... (NOTE:
* we don't use gethostbyname as a fallback!)
/*
* Otherwise use the IPv4-only gethostbyname... (NOTE:
* we don't use gethostbyname as a fallback!)
@@
-209,6
+211,9
@@
SockAddr sk_nonamelookup(const char *host)
ret->family = AF_UNSPEC;
strncpy(ret->hostname, host, lenof(ret->hostname));
ret->hostname[lenof(ret->hostname)-1] = '\0';
ret->family = AF_UNSPEC;
strncpy(ret->hostname, host, lenof(ret->hostname));
ret->hostname[lenof(ret->hostname)-1] = '\0';
+#ifndef NO_IPV6
+ ret->ai = NULL;
+#endif
return ret;
}
return ret;
}
@@
-673,7
+678,7
@@
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i
*/
if (srcaddr) {
a.sin_addr.s_addr = inet_addr(srcaddr);
*/
if (srcaddr) {
a.sin_addr.s_addr = inet_addr(srcaddr);
- if (a.sin_addr.s_addr !=
INADDR_NONE
) {
+ if (a.sin_addr.s_addr !=
(in_addr_t)(-1)
) {
/* Override localhost_only with specified listen addr. */
ret->localhost_only = ipv4_is_loopback(a.sin_addr);
got_addr = 1;
/* Override localhost_only with specified listen addr. */
ret->localhost_only = ipv4_is_loopback(a.sin_addr);
got_addr = 1;