Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 344d89a

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 9016a2a commit 344d89a

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
@@ -177,7 +177,7 @@ search_directory(const char *directory, const char *fname)
177177
if (IsXLogFileName(xlde->d_name))
178178
{
179179
fd = open_file_in_directory(directory, xlde->d_name);
180-
fname = xlde->d_name;
180+
fname = pg_strdup(xlde->d_name);
181181
break;
182182
}
183183
}

0 commit comments

Comments
 (0)