pg.ddx.io  pgpool-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tatsuo Ishii <ishii@postgresql.org>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Fix lifecheck buffer overrun.
Date: Thu, 01 Oct 2026 11:16:32 +0000
Message-ID: <E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org> (raw)

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@sraoss.co.jp>
Backpatch-through: v4.3

Branch
------
V4_4_STABLE

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

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(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org>
Permalink:  ../E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org/
Also on:    postgresql.org/message-id/E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgpool-committers@postgresql.org
  Cc: ishii@postgresql.org
  Subject: Re: pgpool: Fix lifecheck buffer overrun.
  In-Reply-To: <E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org>
  References: <E1xCEm8-0000000BzWj-2k3n@gothos.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox