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

Commit32fecad

Browse files
committed
Clean up gcc warnings. Avoid the bad habit of putting externs in .c
files rather than a header file where they belong. Pay some modicumof attention to picking global routine names that aren't likely toconflict with surrounding applications.
1 parentc63bc32 commit32fecad

File tree

4 files changed

+37
-69
lines changed

4 files changed

+37
-69
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.186 2002/06/14 04:23:17 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.187 2002/06/15 22:06:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -61,13 +61,6 @@ inet_aton(const char *cp, struct in_addr * inp)
6161
}
6262
#endif
6363

64-
#ifdefUSE_SSL
65-
externintsecure_initialize(PGconn*);
66-
externvoidsecure_destroy(void);
67-
externintsecure_open_client(PGconn*);
68-
externvoidsecure_close(PGconn*);
69-
externSSL*PQgetssl(PGconn*);
70-
#endif
7164

7265
#defineNOTIFYLIST_INITIAL_SIZE 10
7366
#defineNOTIFYLIST_GROWBY 10
@@ -968,7 +961,8 @@ connectDBStart(PGconn *conn)
968961
}
969962
if (SSLok=='S')
970963
{
971-
if (secure_initialize(conn)==-1||secure_open_client(conn)==-1)
964+
if (pqsecure_initialize(conn)==-1||
965+
pqsecure_open_client(conn)==-1)
972966
{
973967
gotoconnect_errReturn;
974968
}
@@ -979,7 +973,7 @@ connectDBStart(PGconn *conn)
979973
/* Received error - probably protocol mismatch */
980974
if (conn->Pfdebug)
981975
fprintf(conn->Pfdebug,"Postmaster reports error, attempting fallback to pre-7.0.\n");
982-
secure_close(conn);
976+
pqsecure_close(conn);
983977
#ifdefWIN32
984978
closesocket(conn->sock);
985979
#else
@@ -1021,7 +1015,7 @@ connectDBStart(PGconn *conn)
10211015
connect_errReturn:
10221016
if (conn->sock >=0)
10231017
{
1024-
secure_close(conn);
1018+
pqsecure_close(conn);
10251019
#ifdefWIN32
10261020
closesocket(conn->sock);
10271021
#else
@@ -1896,11 +1890,9 @@ freePGconn(PGconn *conn)
18961890
if (!conn)
18971891
return;
18981892
pqClearAsyncResult(conn);/* deallocate result and curTuple */
1899-
#ifdefUSE_SSL
1900-
secure_close(conn);
1901-
#endif
19021893
if (conn->sock >=0)
19031894
{
1895+
pqsecure_close(conn);
19041896
#ifdefWIN32
19051897
closesocket(conn->sock);
19061898
#else
@@ -1974,7 +1966,7 @@ closePGconn(PGconn *conn)
19741966
*/
19751967
if (conn->sock >=0)
19761968
{
1977-
secure_close(conn);
1969+
pqsecure_close(conn);
19781970
#ifdefWIN32
19791971
closesocket(conn->sock);
19801972
#else

‎src/interfaces/libpq/fe-misc.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.74 2002/06/1520:01:31 momjian Exp $
28+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.75 2002/06/1522:06:09 tgl Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -55,10 +55,6 @@
5555
#include"mb/pg_wchar.h"
5656
#endif
5757

58-
externvoidsecure_close(PGconn*);
59-
externssize_tsecure_read(PGconn*,void*,size_t);
60-
externssize_tsecure_write(PGconn*,constvoid*,size_t);
61-
6258
#defineDONOTICE(conn,message) \
6359
((*(conn)->noticeHook) ((conn)->noticeArg, (message)))
6460

@@ -490,8 +486,8 @@ pqReadData(PGconn *conn)
490486

491487
/* OK, try to read some data */
492488
retry3:
493-
nread=secure_read(conn,conn->inBuffer+conn->inEnd,
494-
conn->inBufSize-conn->inEnd);
489+
nread=pqsecure_read(conn,conn->inBuffer+conn->inEnd,
490+
conn->inBufSize-conn->inEnd);
495491
if (nread<0)
496492
{
497493
if (SOCK_ERRNO==EINTR)
@@ -570,8 +566,8 @@ pqReadData(PGconn *conn)
570566
* arrived.
571567
*/
572568
retry4:
573-
nread=secure_read(conn,conn->inBuffer+conn->inEnd,
574-
conn->inBufSize-conn->inEnd);
569+
nread=pqsecure_read(conn,conn->inBuffer+conn->inEnd,
570+
conn->inBufSize-conn->inEnd);
575571
if (nread<0)
576572
{
577573
if (SOCK_ERRNO==EINTR)
@@ -612,7 +608,7 @@ pqReadData(PGconn *conn)
612608
"\tThis probably means the server terminated abnormally\n"
613609
"\tbefore or while processing the request.\n"));
614610
conn->status=CONNECTION_BAD;/* No more connection to backend */
615-
secure_close(conn);
611+
pqsecure_close(conn);
616612
#ifdefWIN32
617613
closesocket(conn->sock);
618614
#else
@@ -654,7 +650,7 @@ pqSendSome(PGconn *conn)
654650
{
655651
intsent;
656652

657-
sent=secure_write(conn,ptr,len);
653+
sent=pqsecure_write(conn,ptr,len);
658654

659655
if (sent<0)
660656
{

‎src/interfaces/libpq/fe-secure.c

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* fe-connect.c
3+
* fe-secure.c
44
* functions related to setting up a secure connection to the backend.
55
* Secure connections are expected to provide confidentiality,
66
* message integrity and endpoint authentication.
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.4 2002/06/14 04:38:04 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.5 2002/06/15 22:06:09 tgl Exp $
1515
*
1616
* NOTES
1717
* The client *requires* a valid server certificate. Since
@@ -26,7 +26,7 @@
2626
* to sign the server certificate, should be present in the
2727
* "$HOME/.postgresql/root.crt" file. If this file isn't
2828
* readable, or the server certificate can't be validated,
29-
*secure_open_client() will return an error code.
29+
*pqsecure_open_client() will return an error code.
3030
*
3131
* Additionally, the server certificate's "common name" must
3232
* resolve to the other end of the socket. This makes it
@@ -38,7 +38,7 @@
3838
* Unfortunately neither the current front- or back-end handle
3939
* failure gracefully, resulting in the backend hiccupping.
4040
* This points out problems in each (the frontend shouldn't even
41-
* try to do SSL ifsecure_initialize() fails, and the backend
41+
* try to do SSL ifpqsecure_initialize() fails, and the backend
4242
* shouldn't crash/recover if an SSH negotiation fails. The
4343
* backend definitely needs to be fixed, to prevent a "denial
4444
* of service" attack, but I don't know enough about how the
@@ -76,30 +76,6 @@
7676
* The code currently assumes a POSIX password entry. How should
7777
* Windows and Mac users be handled?
7878
*
79-
* PATCH LEVEL
80-
* milestone 1: fix basic coding errors
81-
* [*] existing SSL code pulled out of existing files.
82-
* [*] SSL_get_error() after SSL_read() and SSL_write(),
83-
* SSL_shutdown(), default to TLSv1.
84-
*
85-
* milestone 2: provide endpoint authentication (server)
86-
* [*] client verifies server cert
87-
* [*] client verifies server hostname
88-
*
89-
* milestone 3: improve confidentially, support perfect forward secrecy
90-
* [ ] use 'random' file, read from '/dev/urandom?'
91-
* [*] emphermal DH keys, default values
92-
*
93-
* milestone 4: provide endpoint authentication (client)
94-
* [*] server verifies client certificates
95-
*
96-
* milestone 5: provide informational callbacks
97-
* [*] provide informational callbacks
98-
*
99-
* other changes
100-
* [ ] tcp-wrappers
101-
* [ ] more informative psql
102-
*
10379
*-------------------------------------------------------------------------
10480
*/
10581

@@ -142,12 +118,6 @@
142118
#include<openssl/e_os.h>
143119
#endif/* USE_SSL */
144120

145-
intsecure_initialize(PGconn*);
146-
voidsecure_destroy(void);
147-
intsecure_open_client(PGconn*);
148-
voidsecure_close(PGconn*);
149-
ssize_tsecure_read(PGconn*,void*ptr,size_tlen);
150-
ssize_tsecure_write(PGconn*,constvoid*ptr,size_tlen);
151121

152122
#ifdefUSE_SSL
153123
staticintverify_cb(intok,X509_STORE_CTX*ctx);
@@ -228,7 +198,7 @@ KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI=\n\
228198
*Initialize global context
229199
*/
230200
int
231-
secure_initialize (PGconn*conn)
201+
pqsecure_initialize (PGconn*conn)
232202
{
233203
intr=0;
234204

@@ -243,7 +213,7 @@ secure_initialize (PGconn *conn)
243213
*Destroy global context
244214
*/
245215
void
246-
secure_destroy (void)
216+
pqsecure_destroy (void)
247217
{
248218
#ifdefUSE_SSL
249219
destroy_SSL();
@@ -254,7 +224,7 @@ secure_destroy (void)
254224
*Attempt to negotiate secure session.
255225
*/
256226
int
257-
secure_open_client (PGconn*conn)
227+
pqsecure_open_client (PGconn*conn)
258228
{
259229
intr=0;
260230

@@ -269,7 +239,7 @@ secure_open_client (PGconn *conn)
269239
*Close secure session.
270240
*/
271241
void
272-
secure_close (PGconn*conn)
242+
pqsecure_close (PGconn*conn)
273243
{
274244
#ifdefUSE_SSL
275245
if (conn->ssl)
@@ -281,7 +251,7 @@ secure_close (PGconn *conn)
281251
*Read data from a secure connection.
282252
*/
283253
ssize_t
284-
secure_read (PGconn*conn,void*ptr,size_tlen)
254+
pqsecure_read (PGconn*conn,void*ptr,size_tlen)
285255
{
286256
ssize_tn;
287257

@@ -306,7 +276,7 @@ secure_read (PGconn *conn, void *ptr, size_t len)
306276
libpq_gettext("SSL error: %s\n"),SSLerrmessage());
307277
/* fall through */
308278
caseSSL_ERROR_ZERO_RETURN:
309-
secure_close(conn);
279+
pqsecure_close(conn);
310280
SOCK_ERRNO=ECONNRESET;
311281
n=-1;
312282
break;
@@ -323,7 +293,7 @@ secure_read (PGconn *conn, void *ptr, size_t len)
323293
*Write data to a secure connection.
324294
*/
325295
ssize_t
326-
secure_write (PGconn*conn,constvoid*ptr,size_tlen)
296+
pqsecure_write (PGconn*conn,constvoid*ptr,size_tlen)
327297
{
328298
ssize_tn;
329299

@@ -352,7 +322,7 @@ secure_write (PGconn *conn, const void *ptr, size_t len)
352322
libpq_gettext("SSL error: %s\n"),SSLerrmessage());
353323
/* fall through */
354324
caseSSL_ERROR_ZERO_RETURN:
355-
secure_close(conn);
325+
pqsecure_close(conn);
356326
SOCK_ERRNO=ECONNRESET;
357327
n=-1;
358328
break;
@@ -925,4 +895,5 @@ PQgetssl(PGconn *conn)
925895
returnNULL;
926896
returnconn->ssl;
927897
}
898+
928899
#endif/* USE_SSL */

‎src/interfaces/libpq/libpq-int.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: libpq-int.h,v 1.49 2002/06/14 04:23:17 momjian Exp $
15+
* $Id: libpq-int.h,v 1.50 2002/06/15 22:06:09 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -331,6 +331,15 @@ extern intpqWait(int forRead, int forWrite, PGconn *conn);
331331
externintpqReadReady(PGconn*conn);
332332
externintpqWriteReady(PGconn*conn);
333333

334+
/* === in fe-secure.c === */
335+
336+
externintpqsecure_initialize(PGconn*);
337+
externvoidpqsecure_destroy(void);
338+
externintpqsecure_open_client(PGconn*);
339+
externvoidpqsecure_close(PGconn*);
340+
externssize_tpqsecure_read(PGconn*,void*ptr,size_tlen);
341+
externssize_tpqsecure_write(PGconn*,constvoid*ptr,size_tlen);
342+
334343
/* bits in a byte */
335344
#defineBYTELEN 8
336345

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp