Commit a5ffa8fe authored by Tom Lane's avatar Tom Lane

Guard against bug in Solaris' bsearch(), per Michael Wildpaner.

parent a5a68766
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.117 2003/11/29 19:51:49 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.118 2003/12/05 15:50:31 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -381,6 +381,10 @@ user_group_bsearch_cmp(const void *user, const void *list) ...@@ -381,6 +381,10 @@ user_group_bsearch_cmp(const void *user, const void *list)
static List ** static List **
get_group_line(const char *group) get_group_line(const char *group)
{ {
/* On some versions of Solaris, bsearch of zero items dumps core */
if (group_length == 0)
return NULL;
return (List **) bsearch((void *) group, return (List **) bsearch((void *) group,
(void *) group_sorted, (void *) group_sorted,
group_length, group_length,
...@@ -392,9 +396,13 @@ get_group_line(const char *group) ...@@ -392,9 +396,13 @@ get_group_line(const char *group)
/* /*
* Lookup a user name in the pg_shadow file * Lookup a user name in the pg_shadow file
*/ */
List ** List **
get_user_line(const char *user) get_user_line(const char *user)
{ {
/* On some versions of Solaris, bsearch of zero items dumps core */
if (user_length == 0)
return NULL;
return (List **) bsearch((void *) user, return (List **) bsearch((void *) user,
(void *) user_sorted, (void *) user_sorted,
user_length, user_length,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment