pgsql: waldump: fix use-after-free in search_directory(). - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: waldump: fix use-after-free in search_directory().
Date
Msg-id E1nYeCN-001gWy-RA@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
waldump: fix use-after-free in search_directory().

After closedir() dirent->d_name is not valid anymore. As there alerady are a
few places relying on the limited lifetime of pg_waldump, do so here as well,
and just pg_strdup() the string.

The bug was introduced in fc49e24fa69a.

Found by UBSan, run locally.

Backpatch: 11-, like fc49e24fa69 itself.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/264d284929e0d5a419821f94f16f766b5497c87a

Modified Files
--------------
src/bin/pg_waldump/pg_waldump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: pgsql: Fix up compiler warnings/errors from f4fb45d15.
Next
From: Thomas Munro
Date:
Subject: pgsql: Fix pg_waldump docs.