diff options
author | Andres Freund <andres@anarazel.de> | 2022-03-23 16:38:43 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2022-03-27 18:15:15 -0700 |
commit | 5ebd262dcbacddbd359d08c032fa04bfdf839b36 (patch) | |
tree | c934cf3a7c44c90a5d275a7ba646616fc0e34169 | |
parent | 5ca2aa2f26eaa3c355abd314aa7619f403aa4e4d (diff) | |
download | postgresql-5ebd262dcbacddbd359d08c032fa04bfdf839b36.tar.gz postgresql-5ebd262dcbacddbd359d08c032fa04bfdf839b36.zip |
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.
-rw-r--r-- | src/bin/pg_waldump/pg_waldump.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index b1e5f461045..5d7f52583b8 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -180,7 +180,7 @@ search_directory(const char *directory, const char *fname) if (IsXLogFileName(xlde->d_name)) { fd = open_file_in_directory(directory, xlde->d_name); - fname = xlde->d_name; + fname = pg_strdup(xlde->d_name); break; } } |