Skip to content

Commit 6a3dcd2

Browse files
committed
Fix possible buffer overrun in hba.c.
Coverty reports a possible buffer overrun in the code that populates the pg_hba_file_rules view. It may not be a live bug due to restrictions on options that can be used together, but let's increase MAX_HBA_OPTIONS and correct a nearby misleading comment. Back-patch to 10 where this code arrived. Reported-by: Julian Hsiao Discussion: https://postgr.es/m/CADnGQpzbkWdKS2YHNifwAvX5VEsJ5gW49U4o-7UL5pzyTv4vTg%40mail.gmail.com
1 parent 52b70b1 commit 6a3dcd2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/libpq/hba.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,10 +2218,12 @@ load_hba(void)
22182218
/*
22192219
* This macro specifies the maximum number of authentication options
22202220
* that are possible with any given authentication method that is supported.
2221-
* Currently LDAP supports 10, so the macro value is well above the most any
2222-
* method needs.
2221+
* Currently LDAP supports 11, and there are 3 that are not dependent on
2222+
* the auth method here. It may not actually be possible to set all of them
2223+
* at the same time, but we'll set the macro value high enough to be
2224+
* conservative and avoid warnings from static analysis tools.
22232225
*/
2224-
#define MAX_HBA_OPTIONS 12
2226+
#define MAX_HBA_OPTIONS 14
22252227

22262228
/*
22272229
* Create a text array listing the options specified in the HBA line.
@@ -2327,6 +2329,7 @@ gethba_options(HbaLine *hba)
23272329
CStringGetTextDatum(psprintf("radiusports=%s", hba->radiusports_s));
23282330
}
23292331

2332+
/* If you add more options, consider increasing MAX_HBA_OPTIONS. */
23302333
Assert(noptions <= MAX_HBA_OPTIONS);
23312334

23322335
if (noptions > 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy