Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc9f48b5

Browse files
committed
Check the return value of getcwd(), instead of assuming success.
Kevin Grittner
1 parenta030bfa commitc9f48b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎contrib/pg_upgrade/option.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ parseCommandLine(int argc, char *argv[])
5656
intoption;/* Command line option */
5757
intoptindex=0;/* used by getopt_long */
5858
intos_user_effective_id;
59+
char*return_buf;
5960

6061
user_opts.transfer_mode=TRANSFER_MODE_COPY;
6162

@@ -93,7 +94,9 @@ parseCommandLine(int argc, char *argv[])
9394
if (os_user_effective_id==0)
9495
pg_log(PG_FATAL,"%s: cannot be run as root\n",os_info.progname);
9596

96-
getcwd(os_info.cwd,MAXPGPATH);
97+
return_buf=getcwd(os_info.cwd,MAXPGPATH);
98+
if (return_buf==NULL)
99+
pg_log(PG_FATAL,"Could not access current working directory: %s\n",getErrorText(errno));
97100

98101
while ((option=getopt_long(argc,argv,"d:D:b:B:cgG:kl:o:O:p:P:u:v",
99102
long_options,&optindex))!=-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp