summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2011-11-04 14:40:25 +0000
committerRobert Haas2011-11-04 14:40:25 +0000
commitc9f48b572c773ab88d02e26ccb5b6ff5fea64c05 (patch)
treeedbead2aaead8acedcdf3218a3fe9a2b530dc26f
parenta030bfa6e41edae8a9a68dc8cef7fc7813f69a0a (diff)
Check the return value of getcwd(), instead of assuming success.
Kevin Grittner
-rw-r--r--contrib/pg_upgrade/option.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index 9892b9764d..026f71e562 100644
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -56,6 +56,7 @@ parseCommandLine(int argc, char *argv[])
int option; /* Command line option */
int optindex = 0; /* used by getopt_long */
int os_user_effective_id;
+ char *return_buf;
user_opts.transfer_mode = TRANSFER_MODE_COPY;
@@ -93,7 +94,9 @@ parseCommandLine(int argc, char *argv[])
if (os_user_effective_id == 0)
pg_log(PG_FATAL, "%s: cannot be run as root\n", os_info.progname);
- getcwd(os_info.cwd, MAXPGPATH);
+ return_buf = getcwd(os_info.cwd, MAXPGPATH);
+ if (return_buf == NULL)
+ pg_log(PG_FATAL, "Could not access current working directory: %s\n", getErrorText(errno));
while ((option = getopt_long(argc, argv, "d:D:b:B:cgG:kl:o:O:p:P:u:v",
long_options, &optindex)) != -1)