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

Commit61be11f

Browse files
committed
Make libpq reject non-numeric and out-of-range port numbers with a suitable
error message, rather than blundering on and failing with something opaque.Sam Mason
1 parent799ac99 commit61be11f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.376 2009/07/24 17:58:31 tgl Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.377 2009/09/27 03:43:10 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -817,7 +817,16 @@ connectDBStart(PGconn *conn)
817817

818818
/* Set up port number as a string */
819819
if (conn->pgport!=NULL&&conn->pgport[0]!='\0')
820+
{
820821
portnum=atoi(conn->pgport);
822+
if (portnum<1||portnum>65535)
823+
{
824+
appendPQExpBuffer(&conn->errorMessage,
825+
libpq_gettext("invalid port number: \"%s\"\n"),
826+
conn->pgport);
827+
gotoconnect_errReturn;
828+
}
829+
}
821830
else
822831
portnum=DEF_PGPORT;
823832
snprintf(portstr,sizeof(portstr),"%d",portnum);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp