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

Commitef9f359

Browse files
committed
Add missing bad-PGconn guards in libpq entry points.
There's a convention that externally-visible libpq functions shouldcheck for a NULL PGconn pointer, and fail gracefully instead ofcrashing. PQflush() and PQisnonblocking() didn't get that memothough. Also add a similar check to PQdefaultSSLKeyPassHook_OpenSSL;while it's not clear that ordinary usage could reach that with anull conn pointer, it's cheap enough to check, so let's be consistent.Daniele Varrazzo and Tom LaneDiscussion:https://postgr.es/m/CA+mi_8Zm_mVVyW1iNFgyMd9Oh0Nv8-F+7Y3-BqwMgTMHuo_h2Q@mail.gmail.com
1 parenta5d2337 commitef9f359

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,6 +3922,8 @@ PQsetnonblocking(PGconn *conn, int arg)
39223922
int
39233923
PQisnonblocking(constPGconn*conn)
39243924
{
3925+
if (!conn||conn->status==CONNECTION_BAD)
3926+
return false;
39253927
returnpqIsnonblocking(conn);
39263928
}
39273929

@@ -3941,6 +3943,8 @@ PQisthreadsafe(void)
39413943
int
39423944
PQflush(PGconn*conn)
39433945
{
3946+
if (!conn||conn->status==CONNECTION_BAD)
3947+
return-1;
39443948
returnpqFlush(conn);
39453949
}
39463950

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
19381938
int
19391939
PQdefaultSSLKeyPassHook_OpenSSL(char*buf,intsize,PGconn*conn)
19401940
{
1941-
if (conn->sslpassword)
1941+
if (conn&&conn->sslpassword)
19421942
{
19431943
if (strlen(conn->sslpassword)+1>size)
19441944
fprintf(stderr,libpq_gettext("WARNING: sslpassword truncated\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp