From 63e8c5730918b5e7d4dda7b08b575e9ee568a29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Mon, 18 Jul 2022 19:36:36 +0200 Subject: [PATCH] Fix invalid memory accesses in Aurora monitoring Invalid memory accesses could take place if no servers can be pinged. --- lib/MySQL_Monitor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 6527c54ca..ab8f8d875 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -4294,6 +4294,11 @@ void * monitor_AWS_Aurora_thread_HG(void *arg) { cur_host_idx++; } } + // NOTE: 'cur_host_idx' should never be higher than 'num_hosts' otherwise later an invalid memory access + // can table place later when accessing 'hpa[cur_host_idx]'. + if (cur_host_idx >= num_hosts) { + cur_host_idx = num_hosts - 1; + } pthread_mutex_unlock(&GloMyMon->aws_aurora_mutex); bool exit_now = false;