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

Commita643d97

Browse files
committed
Fix for inet from Tom H.
1 parent5d79f26 commita643d97

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#if defined(LIBC_SCCS)&& !defined(lint)
19-
staticconstcharrcsid[]="$Id: inet_net_pton.c,v 1.3 1998/10/1201:30:26 momjian Exp $";
19+
staticconstcharrcsid[]="$Id: inet_net_pton.c,v 1.4 1998/10/1215:56:34 momjian Exp $";
2020

2121
#endif
2222

@@ -105,7 +105,8 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
105105
/* Hexadecimal: Eat nybble string. */
106106
if (size <=0)
107107
gotoemsgsize;
108-
*dst=0,dirty=0;
108+
tmp=0;
109+
dirty=0;
109110
src++;/* skip x or X. */
110111
while ((ch=*src++)!='\0'&&
111112
isascii(ch)&&isxdigit(ch))
@@ -114,16 +115,20 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
114115
ch=tolower(ch);
115116
n=strchr(xdigits,ch)-xdigits;
116117
assert(n >=0&&n <=15);
117-
*dst |=n;
118-
if (!dirty++)
119-
*dst <<=4;
120-
elseif (--size>0)
121-
*++dst=0,dirty=0;
122-
else
118+
tmp= (tmp <<4) |n;
119+
if (++dirty==2) {
120+
if (size-- <=0)
121+
gotoemsgsize;
122+
*dst++= (u_char)tmp;
123+
tmp=0,dirty=0;
124+
}
125+
}
126+
if (dirty) {
127+
if (size-- <=0)
123128
gotoemsgsize;
129+
tmp <<=4;
130+
*dst++= (u_char)tmp;
124131
}
125-
if (dirty)
126-
size--;
127132
}
128133
elseif (isascii(ch)&&isdigit(ch))
129134
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp