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

Commit4265ed9

Browse files
committed
Check that connection limit is within valid range. IOW, not < -1.
It's missing in older versions too, but it doesn't seem worthback-porting. All negative are just harmlessly treated as "no limit", andtightening the check might even brake an application that relies on it.
1 parentcb629f7 commit4265ed9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.218 2009/01/20 18:59:37 heikki Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.219 2009/01/30 17:24:47 heikki Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -244,7 +244,13 @@ createdb(const CreatedbStmt *stmt)
244244
dbctype=strVal(dctype->arg);
245245

246246
if (dconnlimit&&dconnlimit->arg)
247+
{
247248
dbconnlimit=intVal(dconnlimit->arg);
249+
if (dbconnlimit<-1)
250+
ereport(ERROR,
251+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
252+
errmsg("invalid connection limit: %d",dbconnlimit)));
253+
}
248254

249255
/* obtain OID of proposed owner */
250256
if (dbowner)
@@ -1319,7 +1325,13 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
13191325
}
13201326

13211327
if (dconnlimit)
1328+
{
13221329
connlimit=intVal(dconnlimit->arg);
1330+
if (connlimit<-1)
1331+
ereport(ERROR,
1332+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1333+
errmsg("invalid connection limit: %d",connlimit)));
1334+
}
13231335

13241336
/*
13251337
* Get the old tuple. We don't need a lock on the database per se,

‎src/backend/commands/user.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.185 2009/01/22 20:16:02 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.186 2009/01/30 17:24:47 heikki Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -242,7 +242,13 @@ CreateRole(CreateRoleStmt *stmt)
242242
if (dcanlogin)
243243
canlogin=intVal(dcanlogin->arg)!=0;
244244
if (dconnlimit)
245+
{
245246
connlimit=intVal(dconnlimit->arg);
247+
if (connlimit<-1)
248+
ereport(ERROR,
249+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
250+
errmsg("invalid connection limit: %d",connlimit)));
251+
}
246252
if (daddroleto)
247253
addroleto= (List*)daddroleto->arg;
248254
if (drolemembers)
@@ -533,7 +539,13 @@ AlterRole(AlterRoleStmt *stmt)
533539
if (dcanlogin)
534540
canlogin=intVal(dcanlogin->arg);
535541
if (dconnlimit)
542+
{
536543
connlimit=intVal(dconnlimit->arg);
544+
if (connlimit<-1)
545+
ereport(ERROR,
546+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
547+
errmsg("invalid connection limit: %d",connlimit)));
548+
}
537549
if (drolemembers)
538550
rolemembers= (List*)drolemembers->arg;
539551
if (dvalidUntil)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp