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

Commit09a6c90

Browse files
committed
Fix bogus freeaddrinfo() call in WIN32 code, extend gai_strerror to
cover more error codes. Per Petr Jelinek.
1 parent1a33436 commit09a6c90

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

‎src/include/getaddrinfo.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
1717
*
18-
* $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.15 2005/07/27 12:44:10 neilc Exp $
18+
* $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.16 2005/08/25 17:50:59 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -31,6 +31,7 @@
3131
/* Various macros that ought to be in <netdb.h>, but might not be */
3232

3333
#ifndefEAI_FAIL
34+
#ifndefWIN32
3435
#defineEAI_BADFLAGS(-1)
3536
#defineEAI_NONAME(-2)
3637
#defineEAI_AGAIN(-3)
@@ -40,7 +41,18 @@
4041
#defineEAI_SERVICE(-8)
4142
#defineEAI_MEMORY(-10)
4243
#defineEAI_SYSTEM(-11)
43-
#endif
44+
#else/* WIN32 */
45+
#defineEAI_AGAINWSATRY_AGAIN
46+
#defineEAI_BADFLAGSWSAEINVAL
47+
#defineEAI_FAILWSANO_RECOVERY
48+
#defineEAI_FAMILYWSAEAFNOSUPPORT
49+
#defineEAI_MEMORYWSA_NOT_ENOUGH_MEMORY
50+
#defineEAI_NODATAWSANO_DATA
51+
#defineEAI_NONAMEWSAHOST_NOT_FOUND
52+
#defineEAI_SERVICEWSATYPE_NOT_FOUND
53+
#defineEAI_SOCKTYPEWSAESOCKTNOSUPPORT
54+
#endif/* !WIN32 */
55+
#endif/* !EAI_FAIL */
4456

4557
#ifndefAI_PASSIVE
4658
#defineAI_PASSIVE0x0001

‎src/port/getaddrinfo.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.18 2005/08/24 22:13:23 tgl Exp $
19+
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.19 2005/08/25 17:51:01 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -103,9 +103,12 @@ haveNativeWindowsIPv6routines(void)
103103
{
104104
/* We found a dll, so now get the addresses of the routines */
105105

106-
getaddrinfo_ptr=GetProcAddress(hLibrary,"getaddrinfo");
107-
freeaddrinfo_ptr=GetProcAddress(hLibrary,"freeaddrinfo");
108-
getnameinfo_ptr=GetProcAddress(hLibrary,"getnameinfo");
106+
getaddrinfo_ptr= (getaddrinfo_ptr_t)GetProcAddress(hLibrary,
107+
"getaddrinfo");
108+
freeaddrinfo_ptr= (freeaddrinfo_ptr_t)GetProcAddress(hLibrary,
109+
"freeaddrinfo");
110+
getnameinfo_ptr= (getnameinfo_ptr_t)GetProcAddress(hLibrary,
111+
"getnameinfo");
109112

110113
/*
111114
* If any one of the routines is missing, let's play it safe and
@@ -277,7 +280,7 @@ freeaddrinfo(struct addrinfo * res)
277280
*/
278281
if (haveNativeWindowsIPv6routines())
279282
{
280-
(*freeaddrinfo_ptr) (node,service,hintp,res);
283+
(*freeaddrinfo_ptr) (res);
281284
return;
282285
}
283286
#endif
@@ -310,15 +313,40 @@ gai_strerror(int errcode)
310313
}
311314

312315
returnhstrerror(hcode);
313-
#else/* !HAVE_HSTRERROR */
316+
317+
#else/* !HAVE_HSTRERROR */
314318

315319
switch (errcode)
316320
{
317321
caseEAI_NONAME:
318322
return"Unknown host";
319323
caseEAI_AGAIN:
320324
return"Host name lookup failure";
321-
caseEAI_FAIL:
325+
/* Errors below are probably WIN32 only */
326+
#ifdefEAI_BADFLAGS
327+
caseEAI_BADFLAGS:
328+
return"Invalid argument";
329+
#endif
330+
#ifdefEAI_FAMILY
331+
caseEAI_FAMILY:
332+
return"Address family not supported";
333+
#endif
334+
#ifdefEAI_MEMORY
335+
caseEAI_MEMORY:
336+
return"Not enough memory";
337+
#endif
338+
#ifdefEAI_NODATA
339+
caseEAI_NODATA:
340+
return"No host data of that type was found";
341+
#endif
342+
#ifdefEAI_SERVICE
343+
caseEAI_SERVICE:
344+
return"Class type not found";
345+
#endif
346+
#ifdefEAI_SOCKTYPE
347+
caseEAI_SOCKTYPE:
348+
return"Socket type not supported";
349+
#endif
322350
default:
323351
return"Unknown server error";
324352
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp