FreeBSD Bugzilla – Attachment 219564 Details for
Bug 251055
[PATCH] databases/postgresql13-server: pg_hba_file_rules NULL address and netmask on FreeBSD 11.x
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
fix-bogus-addrlen-in-hba-view.patch
fix-bogus-addrlen-in-hba-view.patch (text/plain), 3.10 KB, created by
VinÃcius Zavam
on 2020-11-11 16:42:55 UTC
(
hide
)
Description:
fix-bogus-addrlen-in-hba-view.patch
Filename:
MIME Type:
Creator:
VinÃcius Zavam
Created:
2020-11-11 16:42:55 UTC
Size:
3.10 KB
patch
obsolete
>diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c >index 4c86fb6087..3a78d2043e 100644 >--- a/src/backend/libpq/hba.c >+++ b/src/backend/libpq/hba.c >@@ -1188,8 +1188,11 @@ parse_hba_line(TokenizedLine *tok_line, int elevel) > > ret = pg_getaddrinfo_all(str, NULL, &hints, &gai_result); > if (ret == 0 && gai_result) >+ { > memcpy(&parsedline->addr, gai_result->ai_addr, > gai_result->ai_addrlen); >+ parsedline->addrlen = gai_result->ai_addrlen; >+ } > else if (ret == EAI_NONAME) > parsedline->hostname = str; > else >@@ -1238,6 +1241,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel) > token->string); > return NULL; > } >+ parsedline->masklen = parsedline->addrlen; > pfree(str); > } > else if (!parsedline->hostname) >@@ -1288,6 +1292,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel) > > memcpy(&parsedline->mask, gai_result->ai_addr, > gai_result->ai_addrlen); >+ parsedline->masklen = gai_result->ai_addrlen; > pg_freeaddrinfo_all(hints.ai_family, gai_result); > > if (parsedline->addr.ss_family != parsedline->mask.ss_family) >@@ -2538,20 +2543,26 @@ fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc, > } > else > { >- if (pg_getnameinfo_all(&hba->addr, sizeof(hba->addr), >- buffer, sizeof(buffer), >- NULL, 0, >- NI_NUMERICHOST) == 0) >+ /* >+ * Note: if pg_getnameinfo_all fails, it'll set buffer to >+ * "???", which we want to return. >+ */ >+ if (hba->addrlen > 0) > { >- clean_ipv6_addr(hba->addr.ss_family, buffer); >+ if (pg_getnameinfo_all(&hba->addr, hba->addrlen, >+ buffer, sizeof(buffer), >+ NULL, 0, >+ NI_NUMERICHOST) == 0) >+ clean_ipv6_addr(hba->addr.ss_family, buffer); > addrstr = pstrdup(buffer); > } >- if (pg_getnameinfo_all(&hba->mask, sizeof(hba->mask), >- buffer, sizeof(buffer), >- NULL, 0, >- NI_NUMERICHOST) == 0) >+ if (hba->masklen > 0) > { >- clean_ipv6_addr(hba->mask.ss_family, buffer); >+ if (pg_getnameinfo_all(&hba->mask, hba->masklen, >+ buffer, sizeof(buffer), >+ NULL, 0, >+ NI_NUMERICHOST) == 0) >+ clean_ipv6_addr(hba->mask.ss_family, buffer); > maskstr = pstrdup(buffer); > } > } >diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h >index d638479d88..8f09b5638f 100644 >--- a/src/include/libpq/hba.h >+++ b/src/include/libpq/hba.h >@@ -42,6 +42,10 @@ typedef enum UserAuth > #define USER_AUTH_LAST uaPeer /* Must be last value of this enum */ > } UserAuth; > >+/* >+ * Data structures representing pg_hba.conf entries >+ */ >+ > typedef enum IPCompareMethod > { > ipCmpMask, >@@ -75,11 +79,12 @@ typedef struct HbaLine > List *databases; > List *roles; > struct sockaddr_storage addr; >+ int addrlen; /* zero if we don't have a valid addr */ > struct sockaddr_storage mask; >+ int masklen; /* zero if we don't have a valid mask */ > IPCompareMethod ip_cmp_method; > char *hostname; > UserAuth auth_method; >- > char *usermap; > char *pamservice; > bool pam_use_hostname;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251055
: 219564