Fix a potential backend crash during authentication when parsing a

malformed ident map file.  This was introduced by the linked list
rewrite in 8.0 -- mea maxima culpa.

Per Coverity static analysis performed by EnterpriseDB.
This commit is contained in:
Neil Conway 2005-06-21 01:20:09 +00:00
parent 09d1110c2a
commit ec3a1af0a8
1 changed files with 9 additions and 16 deletions

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.140 2005/02/26 18:43:33 tgl Exp $ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.141 2005/06/21 01:20:09 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1135,16 +1135,16 @@ parse_ident_usermap(List *line, int line_number, const char *usermap_name,
token = lfirst(line_item); token = lfirst(line_item);
file_map = token; file_map = token;
/* Get the ident user token (must be provided) */ /* Get the ident user token */
line_item = lnext(line_item); line_item = lnext(line_item);
if (!line) if (!line_item)
goto ident_syntax; goto ident_syntax;
token = lfirst(line_item); token = lfirst(line_item);
file_ident_user = token; file_ident_user = token;
/* Get the PG username token */ /* Get the PG username token */
line_item = lnext(line_item); line_item = lnext(line_item);
if (!line) if (!line_item)
goto ident_syntax; goto ident_syntax;
token = lfirst(line_item); token = lfirst(line_item);
file_pguser = token; file_pguser = token;
@ -1154,21 +1154,14 @@ parse_ident_usermap(List *line, int line_number, const char *usermap_name,
strcmp(file_pguser, pg_user) == 0 && strcmp(file_pguser, pg_user) == 0 &&
strcmp(file_ident_user, ident_user) == 0) strcmp(file_ident_user, ident_user) == 0)
*found_p = true; *found_p = true;
return; return;
ident_syntax: ident_syntax:
if (line_item) ereport(LOG,
ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR),
(errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("missing entry in file \"%s\" at end of line %d",
errmsg("invalid entry in file \"%s\" at line %d, token \"%s\"", IdentFileName, line_number)));
IdentFileName, line_number,
(const char *) lfirst(line_item))));
else
ereport(LOG,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("missing entry in file \"%s\" at end of line %d",
IdentFileName, line_number)));
*error_p = true; *error_p = true;
} }