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

Commit87d014d

Browse files
committed
createuser: fix parsing of --connection-limit argument
The original coding failed to quote the argument properly.Reported-by: Daniel GustafssonDiscussion: 1B8AE66C-85AB-4728-9BB4-612E8E61C219@yesql.se
1 parent2ad1253 commit87d014d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎src/bin/scripts/createuser.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ main(int argc, char *argv[])
6363
enumtrivalueprompt_password=TRI_DEFAULT;
6464
boolecho= false;
6565
boolinteractive= false;
66-
char*conn_limit=NULL;
66+
intconn_limit=-2;/* less than minimum valid value */
6767
boolpwprompt= false;
6868
char*newpassword=NULL;
6969
charnewuser_buf[128];
@@ -91,6 +91,8 @@ main(int argc, char *argv[])
9191
while ((c=getopt_long(argc,argv,"h:p:U:g:wWedDsSaArRiIlLc:PE",
9292
long_options,&optindex))!=-1)
9393
{
94+
char*endptr;
95+
9496
switch (c)
9597
{
9698
case'h':
@@ -147,7 +149,14 @@ main(int argc, char *argv[])
147149
login=TRI_NO;
148150
break;
149151
case'c':
150-
conn_limit=pg_strdup(optarg);
152+
conn_limit=strtol(optarg,&endptr,10);
153+
if (*endptr!='\0'||conn_limit<-1)/* minimum valid value */
154+
{
155+
fprintf(stderr,
156+
_("%s: invalid value for --connection-limit: %s\n"),
157+
progname,optarg);
158+
exit(1);
159+
}
151160
break;
152161
case'P':
153162
pwprompt= true;
@@ -302,8 +311,8 @@ main(int argc, char *argv[])
302311
appendPQExpBufferStr(&sql," REPLICATION");
303312
if (replication==TRI_NO)
304313
appendPQExpBufferStr(&sql," NOREPLICATION");
305-
if (conn_limit!=NULL)
306-
appendPQExpBuffer(&sql," CONNECTION LIMIT %s",conn_limit);
314+
if (conn_limit>=-1)
315+
appendPQExpBuffer(&sql," CONNECTION LIMIT %d",conn_limit);
307316
if (roles.head!=NULL)
308317
{
309318
SimpleStringListCell*cell;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp