Skip to content

Commit dabc3f3

Browse files
committed
Fix for netmask('x.x.x.x/0') is 255.255.255.255 instead of 0.0.0.0
This is because (-1) << 32 is -1 (Only intel arc. has been checked) Oleg Sharoiko
1 parent 337ab80 commit dabc3f3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

doc/TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ PARSER
4848
* redesign INSERT ... SELECT to have two levels of target list
4949
* -select * from pg_class where oid in (0,-1)
5050
* have INTERSECT/EXCEPT prevent duplicates unless ALL is specified
51+
* prevent primary key of nine columns(see TODO.detail/primary)
5152

5253
VIEWS
5354

src/backend/utils/adt/network.c

Lines changed: 3 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.15 1999/07/17 20:17:58 momjian Exp $
6+
* $Id: network.c,v 1.16 1999/09/23 17:42:23 momjian Exp $
77
* Jon Postel RIP 16 Oct 1998
88
*/
99

@@ -448,7 +448,8 @@ network_netmask(inet *ip)
448448
if (ip_family(ip) == AF_INET)
449449
{
450450
/* It's an IP V4 address: */
451-
int addr = htonl((-1 << (32 - ip_bits(ip))) & 0xffffffff);
451+
int addr = htonl(ip_bits(ip) ?
452+
(-1 << (32 - ip_bits(ip))) & 0xffffffff : 0x00000000);
452453

453454
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
454455
elog(ERROR, "unable to print netmask (%s)", strerror(errno));

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