Skip to content

Commit 0381fef

Browse files
committed
Fix pg_rewind's handling of top-level symlinks.
The previous coding suffered a null-pointer dereference if it found any symlink at the top level of $PGDATA. Fix that, and teach it to recurse into a symlink for pg_xlog, but not anything else. Per note from Abhijit Menon-Sen.
1 parent e5f1a4f commit 0381fef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/bin/pg_rewind/copy_fetch.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ traverse_datadir(const char *datadir, process_file_callback_t callback)
4242

4343
/*
4444
* recursive part of traverse_datadir
45+
*
46+
* parent_path is the current subdirectory's path relative to datadir,
47+
* or NULL at the top level.
4548
*/
4649
static void
4750
recurse_dir(const char *datadir, const char *parentpath,
@@ -127,9 +130,11 @@ recurse_dir(const char *datadir, const char *parentpath,
127130

128131
/*
129132
* If it's a symlink within pg_tblspc, we need to recurse into it,
130-
* to process all the tablespaces.
133+
* to process all the tablespaces. We also follow a symlink if
134+
* it's for pg_xlog. Symlinks elsewhere are ignored.
131135
*/
132-
if (strcmp(parentpath, "pg_tblspc") == 0)
136+
if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
137+
strcmp(path, "pg_xlog") == 0)
133138
recurse_dir(datadir, path, callback);
134139
#else
135140
pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform\n",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy