Skip to content

Commit 5ebd262

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 5ca2aa2 commit 5ebd262

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
@@ -180,7 +180,7 @@ search_directory(const char *directory, const char *fname)
180180
if (IsXLogFileName(xlde->d_name))
181181
{
182182
fd = open_file_in_directory(directory, xlde->d_name);
183-
fname = xlde->d_name;
183+
fname = pg_strdup(xlde->d_name);
184184
break;
185185
}
186186
}

0 commit comments

Comments
 (0)