diff options
author | Matt Johnston <matt@ucc.asn.au> | 2005-01-02 12:04:45 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2005-01-02 12:04:45 +0000 |
commit | b9bd1cab36d36c73362b894fec7a03b275e81e09 (patch) | |
tree | dc07fd0e6cfa400ea76f55d7368f12a37b07db06 | |
parent | c80c9ecc46607a18ce90fba41672ef9ba616facc (diff) | |
download | dropbear-b9bd1cab36d36c73362b894fec7a03b275e81e09.tar.gz |
Fix so that getnameinfo() is passed the address-specific structure size. This
lets it work on Solaris (and probably other platforms)
-rw-r--r-- | dbutil.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -357,6 +357,16 @@ unsigned char * getaddrstring(struct sockaddr_storage* addr, int withport) { unsigned int len; len = sizeof(struct sockaddr_storage); + /* Some platforms such as Solaris 8 require that len is the length + * of the specific structure. */ + if (addr->ss_family == AF_INET) { + len = sizeof(struct sockaddr_in); + } +#ifdef AF_INET6 + if (addr->ss_family == AF_INET6) { + len = sizeof(struct sockaddr_in6); + } +#endif ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST); @@ -389,6 +399,16 @@ char* getaddrhostname(struct sockaddr_storage * addr) { unsigned int len; len = sizeof(struct sockaddr_storage); + /* Some platforms such as Solaris 8 require that len is the length + * of the specific structure. */ + if (addr->ss_family == AF_INET) { + len = sizeof(struct sockaddr_in); + } +#ifdef AF_INET6 + if (addr->ss_family == AF_INET6) { + len = sizeof(struct sockaddr_in6); + } +#endif ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICSERV); |