waldump: fix use-after-free in search_directory().

Andres Freund <andres@anarazel.de>

Commit: 344d89abf36b9ea559a4b25543bbc7d4206988f5
Author: Andres Freund <andres@anarazel.de>
Date: 2022-03-28T01:15:14Z
Releases: 13.7
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.

Files

PathChange+/−
src/bin/pg_waldump/pg_waldump.c modified +1 −1