pgpool: Fix lifecheck buffer overrun.

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgpool-committers(at)lists(dot)postgresql(dot)org
Subject: pgpool: Fix lifecheck buffer overrun.
Date: 2026-10-01 11:16:37
Message-ID: E1xCEmD-0000000BzY2-1oJH@gothos.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-committers

Fix lifecheck buffer overrun.

load_watchdog_nodes_from_json() in wd_lifecheck.c used strcpy() to
copy WDNodeInfo.stateName to lifeCheckNode.stateName. As the size of
WDNodeInfo.stateName is WD_MAX_HOST_NAMELEN (254), while the size of
lifeCheckNode.stateName was 128, theoretically it was possible for the
strcpy() to overrun lifeCheckNode.stateName. Fortunately strings used
for WDNodeInfo.stateName are predefined as global variable
(wd_state_names in watchdog.c), and never exceeds 128 bytes at this
point. But bug is a bug.

To fix this, change the size of LifeCheckNode.stateName from 128 to
WD_MAX_HOST_NAMELEN, which aligns with WDNodeInfo.stateName.

In passing following changes are made:

- Eliminate use of strcpy() in load_watchdog_nodes_from_json(),
instead use strlcpy().

- Fix the size of WDNodeInfo.nodeName which was mistakenly defined as
WD_MAX_HOST_NAMELEN. Correct one is WD_MAX_NODE_NAMELEN.

Author: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
Backpatch-through: v4.3

Branch
------
V4_5_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=e80c3a313c1dbc6286db14924beaf6bfdb0999e5

Modified Files
--------------
src/include/watchdog/wd_commands.h | 2 +-
src/include/watchdog/wd_lifecheck.h | 2 +-
src/watchdog/wd_lifecheck.c | 9 ++++++---
3 files changed, 8 insertions(+), 5 deletions(-)

Browse pgpool-committers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-10-01 11:16:42 pgpool: Fix lifecheck buffer overrun.
Previous Message Tatsuo Ishii 2026-10-01 11:16:32 pgpool: Fix lifecheck buffer overrun.