pgpool2.git / summary / log / commit / refs
commit 1fdb58301fe3255f9a8c1c8a36e7bcb2b2458141
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Wed May 29 17:33:39 2019 +0000
Fix segfault of worker process if sr_check_user does not have enough privilege.
If sr_check_user does not have enough privilege, selecting on
pg_stat_replication returns some columns to be NULL, which caused a
segfault.
src/streaming_replication/pool_worker_child.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/streaming_replication/pool_worker_child.c b/src/streaming_replication/pool_worker_child.c
index 7687ff025..40096ea2e 100644
--- a/src/streaming_replication/pool_worker_child.c
+++ b/src/streaming_replication/pool_worker_child.c
@@ -416,8 +416,18 @@ check_replication_time_lag(void)
res_rep->numrows > 0 &&
res_rep->nullflags[0] != -1)
{
- strlcpy(bkinfo->replication_state, res_rep->data[1], NAMEDATALEN);
- strlcpy(bkinfo->replication_sync_state, res_rep->data[2], NAMEDATALEN);
+ char *s;
+
+ /*
+ * If sr_check_user has enough privilege, it should return
+ * some string. If not, NULL pointer will be returned for
+ * res_rep->data[1] and [2]. So we need to prepare for the
+ * latter case.
+ */
+ s = res_rep->data[1]? res_rep->data[1] : "";
+ strlcpy(bkinfo->replication_state, s, NAMEDATALEN);
+ s = res_rep->data[1]? res_rep->data[2] : "";
+ strlcpy(bkinfo->replication_sync_state, s, NAMEDATALEN);
free_select_result(res_rep);
}
pfree(query_buf);
[parent: e13b2d2e91a1]