summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-01-02 12:04:45 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-01-02 12:04:45 +0000
commitb9bd1cab36d36c73362b894fec7a03b275e81e09 (patch)
treedc07fd0e6cfa400ea76f55d7368f12a37b07db06
parentc80c9ecc46607a18ce90fba41672ef9ba616facc (diff)
downloaddropbear-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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/dbutil.c b/dbutil.c
index cf57118..ce43933 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -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);