Skip to content

Commit 7d935bd

Browse files
committed
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 fc49e24. Found by UBSan, run locally. Backpatch: 11-, like fc49e24 itself.
1 parent 1a2fdf8 commit 7d935bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bin/pg_waldump/pg_waldump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ search_directory(const char *directory, const char *fname)
198198
if (IsXLogFileName(xlde->d_name))
199199
{
200200
fd = open_file_in_directory(directory, xlde->d_name);
201-
fname = xlde->d_name;
201+
fname = pg_strdup(xlde->d_name);
202202
break;
203203
}
204204
}

0 commit comments

Comments
 (0)