Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7bdea62

Browse files
committed
Fix libpq example programs
When these programs call pg_catalog.set_config, they need to check for PGRES_TUPLES_OK instead of PGRES_COMMAND_OK. Fix for 5770172. Reported-by: Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
1 parent 56b4da8 commit 7bdea62

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

doc/src/sgml/libpq.sgml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8440,7 +8440,7 @@ main(int argc, char **argv)
84408440
/* Set always-secure search path, so malicous users can't take control. */
84418441
res = PQexec(conn,
84428442
"SELECT pg_catalog.set_config('search_path', '', false)");
8443-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
8443+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
84448444
{
84458445
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
84468446
PQclear(res);
@@ -8610,7 +8610,7 @@ main(int argc, char **argv)
86108610
/* Set always-secure search path, so malicous users can't take control. */
86118611
res = PQexec(conn,
86128612
"SELECT pg_catalog.set_config('search_path', '', false)");
8613-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
8613+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
86148614
{
86158615
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
86168616
PQclear(res);

doc/src/sgml/lobj.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ main(int argc, char **argv)
936936
/* Set always-secure search path, so malicous users can't take control. */
937937
res = PQexec(conn,
938938
"SELECT pg_catalog.set_config('search_path', '', false)");
939-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
939+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
940940
{
941941
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
942942
PQclear(res);

src/test/examples/testlibpq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ main(int argc, char **argv)
5151
/* Set always-secure search path, so malicous users can't take control. */
5252
res = PQexec(conn,
5353
"SELECT pg_catalog.set_config('search_path', '', false)");
54-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
54+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
5555
{
5656
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
5757
PQclear(res);

src/test/examples/testlibpq2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ main(int argc, char **argv)
8080
/* Set always-secure search path, so malicous users can't take control. */
8181
res = PQexec(conn,
8282
"SELECT pg_catalog.set_config('search_path', '', false)");
83-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
83+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
8484
{
8585
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
8686
PQclear(res);

src/test/examples/testlibpq4.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName)
3737
/* Set always-secure search path, so malicous users can't take control. */
3838
res = PQexec(conn,
3939
"SELECT pg_catalog.set_config('search_path', '', false)");
40-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
40+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
4141
{
4242
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
4343
PQclear(res);

src/test/examples/testlo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ main(int argc, char **argv)
235235
/* Set always-secure search path, so malicous users can't take control. */
236236
res = PQexec(conn,
237237
"SELECT pg_catalog.set_config('search_path', '', false)");
238-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
238+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
239239
{
240240
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
241241
PQclear(res);

src/test/examples/testlo64.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ main(int argc, char **argv)
259259
/* Set always-secure search path, so malicous users can't take control. */
260260
res = PQexec(conn,
261261
"SELECT pg_catalog.set_config('search_path', '', false)");
262-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
262+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
263263
{
264264
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
265265
PQclear(res);

0 commit comments

Comments
 (0)