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

Commit2d53003

Browse files
committed
Complain if too many options are passed to pg_controldata or pg_resetxlog.
1 parent22b743b commit2d53003

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

‎src/bin/pg_controldata/pg_controldata.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ main(int argc, char *argv[])
142142
DataDir=getenv("PGDATA");
143143
}
144144

145+
/* Complain if any arguments remain */
146+
if (optind<argc)
147+
{
148+
fprintf(stderr,_("%s: too many command-line arguments (first is \"%s\")\n"),
149+
progname,argv[optind]);
150+
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),
151+
progname);
152+
exit(1);
153+
}
154+
145155
if (DataDir==NULL)
146156
{
147157
fprintf(stderr,_("%s: no data directory specified\n"),progname);

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,25 @@ main(int argc, char *argv[])
237237
}
238238
}
239239

240-
if (DataDir==NULL&&optind==argc)
240+
if (DataDir==NULL&&optind<argc)
241+
DataDir=argv[optind++];
242+
243+
/* Complain if any arguments remain */
244+
if (optind<argc)
245+
{
246+
fprintf(stderr,_("%s: too many command-line arguments (first is \"%s\")\n"),
247+
progname,argv[optind]);
248+
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),
249+
progname);
250+
exit(1);
251+
}
252+
253+
if (DataDir==NULL)
241254
{
242255
fprintf(stderr,_("%s: no data directory specified\n"),progname);
243256
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
244257
exit(1);
245258
}
246-
if (DataDir==NULL)
247-
DataDir=argv[optind];
248259

249260
/*
250261
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp