Skip to content

Commit e47b93d

Browse files
committed
The INET and CIDR types mistakenly compared 198.68.123.0/24 and
198.68.123.0/27 the same when indexing them. D'Arcy
1 parent 8593e1f commit e47b93d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/backend/utils/adt/network.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* is for IP V4 CIDR notation, but prepared for V6: just
44
* add the necessary bits where the comments indicate.
55
*
6-
* $Id: network.c,v 1.9 1999/05/25 16:12:11 momjian Exp $
6+
* $Id: network.c,v 1.10 1999/06/02 03:37:15 momjian Exp $
77
* Jon Postel RIP 16 Oct 1998
88
*/
99

@@ -306,8 +306,16 @@ network_cmp(inet *a1, inet *a2)
306306
{
307307
if (ntohl(ip_v4addr(a1)) < ntohl(ip_v4addr(a2)))
308308
return (-1);
309-
else if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
309+
310+
if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
311+
return (1);
312+
313+
if (ip_bits(a1) < ip_bits(a2))
314+
return (-1);
315+
316+
if (ip_bits(a1) > ip_bits(a2))
310317
return (1);
318+
311319
return 0;
312320
}
313321

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy