summaryrefslogtreecommitdiffhomepage
path: root/dbutil.c
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
commite6c957caaa0ca262528adb282357efcaef8b25b1 (patch)
treedc07fd0e6cfa400ea76f55d7368f12a37b07db06 /dbutil.c
parent6d752982848c1dba3c776ec8365c7811322cbd73 (diff)
Fix so that getnameinfo() is passed the address-specific structure size. This
lets it work on Solaris (and probably other platforms) --HG-- extra : convert_revision : b486b773f163af8462b0ef6565ac4285a54708eb
Diffstat (limited to 'dbutil.c')
-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);