Commit 6839aa7a authored by Andres Freund's avatar Andres Freund

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 fc49e24f.

Found by UBSan, run locally.

Backpatch: 11-, like fc49e24f itself.
parent 3f7a59c5
...@@ -177,7 +177,7 @@ search_directory(const char *directory, const char *fname) ...@@ -177,7 +177,7 @@ search_directory(const char *directory, const char *fname)
if (IsXLogFileName(xlde->d_name)) if (IsXLogFileName(xlde->d_name))
{ {
fd = open_file_in_directory(directory, xlde->d_name); fd = open_file_in_directory(directory, xlde->d_name);
fname = xlde->d_name; fname = pg_strdup(xlde->d_name);
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment