aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1998-10-29 04:41:44 +0000
committerBruce Momjian <bruce@momjian.us>1998-10-29 04:41:44 +0000
commit374d9a1f2b52213dba1d50123bf5d81bb19d05a8 (patch)
treef6c7825c169050d35f9438760a7a10d853ea47bc
parent94e37a30da6ec5b267595a2703e424d0272c3c2d (diff)
downloadpostgresql-374d9a1f2b52213dba1d50123bf5d81bb19d05a8.tar.gz
postgresql-374d9a1f2b52213dba1d50123bf5d81bb19d05a8.zip
D'Arcy INET fix.
-rw-r--r--src/backend/utils/adt/network.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index 4e09af623d5..915129480f6 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
- * $Id: network.c,v 1.2 1998/10/26 01:03:24 tgl Exp $
+ * $Id: network.c,v 1.3 1998/10/29 04:41:44 momjian Exp $
* Jon Postel RIP 16 Oct 1998
*/
@@ -395,9 +395,9 @@ network_network(inet *ip)
if (ip_family(ip) == AF_INET)
{
/* It's an IP V4 address: */
- int addr = ntohl(ip_v4addr(ip)) & (0xffffffff << (32 - ip_bits(ip)));
-
- if (inet_cidr_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
+ int addr = htonl(ntohl(ip_v4addr(ip)) & (0xffffffff << (32 - ip_bits(ip))));
+
+ if (inet_cidr_ntop(AF_INET, &addr, ip_bits(ip), tmp, sizeof(tmp)) < 0)
{
elog(ERROR, "unable to print network (%s)", strerror(errno));
return (NULL);
@@ -409,8 +409,6 @@ network_network(inet *ip)
elog(ERROR, "unknown address family (%d)", ip_family(ip));
return (NULL);
}
- if ((ptr = strchr(tmp, '/')) != NULL)
- *ptr = 0;
len = VARHDRSZ + strlen(tmp) + 1;
ret = palloc(len);
if (ret == NULL)