mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
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 5770172cb0c9df9e6ce27c507b449557e5b45124. Reported-by: Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>
This commit is contained in:
parent
c91ac358b1
commit
d5ad0e19d1
@ -7977,7 +7977,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
@ -8147,7 +8147,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -902,7 +902,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -51,7 +51,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -80,7 +80,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -37,7 +37,7 @@ check_prepare_conn(PGconn *conn, const char *dbName)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -235,7 +235,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
@ -259,7 +259,7 @@ main(int argc, char **argv)
|
|||||||
/* Set always-secure search path, so malicous users can't take control. */
|
/* Set always-secure search path, so malicous users can't take control. */
|
||||||
res = PQexec(conn,
|
res = PQexec(conn,
|
||||||
"SELECT pg_catalog.set_config('search_path', '', false)");
|
"SELECT pg_catalog.set_config('search_path', '', false)");
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user