Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite490ee8

Browse files
committed
inet_recv() wasn't IPv6-ready.
1 parentec15013 commite490ee8

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

‎src/backend/utils/adt/network.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
*PostgreSQL type definitions for the INET and CIDR types.
33
*
4-
*$Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.43 2003/07/27 04:53:07 tgl Exp $
4+
*$Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.44 2003/08/01 23:22:52 tgl Exp $
55
*
66
*Jon Postel RIP 16 Oct 1998
77
*/
@@ -45,7 +45,6 @@ static int ip_addrsize(inet *inetptr);
4545
(ip_family(inetptr) == PGSQL_AF_INET ? 32 : 128)
4646

4747
/*
48-
* Now, as a function!
4948
* Return the number of bytes of storage needed for this data type.
5049
*/
5150
staticint
@@ -76,11 +75,10 @@ network_in(char *src, int type)
7675
* if there is one present, assume it's V6, otherwise assume it's V4.
7776
*/
7877

79-
if (strchr(src,':')!=NULL) {
78+
if (strchr(src,':')!=NULL)
8079
ip_family(dst)=PGSQL_AF_INET6;
81-
}else {
80+
else
8281
ip_family(dst)=PGSQL_AF_INET;
83-
}
8482

8583
bits=inet_net_pton(ip_family(dst),src,ip_addr(dst),
8684
type ?ip_addrsize(dst) :-1);
@@ -188,7 +186,8 @@ inet_recv(PG_FUNCTION_ARGS)
188186
addr= (inet*)palloc0(VARHDRSZ+sizeof(inet_struct));
189187

190188
ip_family(addr)=pq_getmsgbyte(buf);
191-
if (ip_family(addr)!=AF_INET)
189+
if (ip_family(addr)!=PGSQL_AF_INET&&
190+
ip_family(addr)!=PGSQL_AF_INET6)
192191
ereport(ERROR,
193192
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
194193
errmsg("invalid family in external inet")));
@@ -218,7 +217,7 @@ inet_recv(PG_FUNCTION_ARGS)
218217

219218
/*
220219
* Error check: CIDR values must not have any bits set beyond the
221-
* masklen. XXX this code is not IPV6 ready.
220+
* masklen.
222221
*/
223222
if (ip_type(addr))
224223
{
@@ -902,12 +901,10 @@ addressOK(unsigned char *a, int bits, int family)
902901
maxbits=128;
903902
maxbytes=16;
904903
}
905-
#if0
906-
assert(bits <=maxbits);
907-
#endif
904+
Assert(bits <=maxbits);
908905

909906
if (bits==maxbits)
910-
return1;
907+
returntrue;
911908

912909
byte= (bits+7) /8;
913910
nbits=bits %8;
@@ -917,12 +914,12 @@ addressOK(unsigned char *a, int bits, int family)
917914

918915
while (byte<maxbytes) {
919916
if ((a[byte]&mask)!=0)
920-
return0;
917+
returnfalse;
921918
mask=0xff;
922919
byte++;
923920
}
924921

925-
return1;
922+
returntrue;
926923
}
927924

928925

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp