pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. @ 2020-11-03 02:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-11-03 02:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix unportable use of getnameinfo() in pg_hba_file_rules view. fill_hba_line() thought it could get away with passing sizeof(struct sockaddr_storage) rather than the actual addrlen previously returned by getaddrinfo(). While that appears to work on many platforms, it does not work on FreeBSD 11: you get back a failure, which leads to the view showing NULL for the address and netmask columns in all rows. The POSIX spec for getnameinfo() is pretty clearly on FreeBSD's side here: you should pass the actual address length. So it seems plausible that there are other platforms where this coding also fails, and we just hadn't noticed. Also, IMO the fact that getnameinfo() failure leads to a NULL output is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is careful to emit "???" on failure, and we should use that in such cases. NULL should only be emitted in rows that don't have IP addresses. Per bug #16695 from Peter Vandivier. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/16695-a665558e2f630be7@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7827497ba2e64fad80d44841758c2ec101f099f9 Modified Files -------------- src/backend/libpq/hba.c | 31 +++++++++++++++++++++---------- src/include/libpq/hba.h | 6 ++++++ 2 files changed, 27 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. @ 2020-11-03 02:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-11-03 02:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix unportable use of getnameinfo() in pg_hba_file_rules view. fill_hba_line() thought it could get away with passing sizeof(struct sockaddr_storage) rather than the actual addrlen previously returned by getaddrinfo(). While that appears to work on many platforms, it does not work on FreeBSD 11: you get back a failure, which leads to the view showing NULL for the address and netmask columns in all rows. The POSIX spec for getnameinfo() is pretty clearly on FreeBSD's side here: you should pass the actual address length. So it seems plausible that there are other platforms where this coding also fails, and we just hadn't noticed. Also, IMO the fact that getnameinfo() failure leads to a NULL output is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is careful to emit "???" on failure, and we should use that in such cases. NULL should only be emitted in rows that don't have IP addresses. Per bug #16695 from Peter Vandivier. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/16695-a665558e2f630be7@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f28b089cbd3541a6df05a7e2907e40b5e516a063 Modified Files -------------- src/backend/libpq/hba.c | 31 +++++++++++++++++++++---------- src/include/libpq/hba.h | 6 ++++++ 2 files changed, 27 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. @ 2020-11-03 02:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-11-03 02:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix unportable use of getnameinfo() in pg_hba_file_rules view. fill_hba_line() thought it could get away with passing sizeof(struct sockaddr_storage) rather than the actual addrlen previously returned by getaddrinfo(). While that appears to work on many platforms, it does not work on FreeBSD 11: you get back a failure, which leads to the view showing NULL for the address and netmask columns in all rows. The POSIX spec for getnameinfo() is pretty clearly on FreeBSD's side here: you should pass the actual address length. So it seems plausible that there are other platforms where this coding also fails, and we just hadn't noticed. Also, IMO the fact that getnameinfo() failure leads to a NULL output is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is careful to emit "???" on failure, and we should use that in such cases. NULL should only be emitted in rows that don't have IP addresses. Per bug #16695 from Peter Vandivier. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/16695-a665558e2f630be7@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/0a4b34031279d938c2e59df8df7159d6c11e39b5 Modified Files -------------- src/backend/libpq/hba.c | 31 +++++++++++++++++++++---------- src/include/libpq/hba.h | 7 ++++++- 2 files changed, 27 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. @ 2020-11-03 02:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-11-03 02:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix unportable use of getnameinfo() in pg_hba_file_rules view. fill_hba_line() thought it could get away with passing sizeof(struct sockaddr_storage) rather than the actual addrlen previously returned by getaddrinfo(). While that appears to work on many platforms, it does not work on FreeBSD 11: you get back a failure, which leads to the view showing NULL for the address and netmask columns in all rows. The POSIX spec for getnameinfo() is pretty clearly on FreeBSD's side here: you should pass the actual address length. So it seems plausible that there are other platforms where this coding also fails, and we just hadn't noticed. Also, IMO the fact that getnameinfo() failure leads to a NULL output is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is careful to emit "???" on failure, and we should use that in such cases. NULL should only be emitted in rows that don't have IP addresses. Per bug #16695 from Peter Vandivier. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/16695-a665558e2f630be7@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d3befe9b98d523d7ae04d93c295001385550e4a3 Modified Files -------------- src/backend/libpq/hba.c | 31 +++++++++++++++++++++---------- src/include/libpq/hba.h | 6 ++++++ 2 files changed, 27 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. @ 2020-11-03 02:12 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-11-03 02:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix unportable use of getnameinfo() in pg_hba_file_rules view. fill_hba_line() thought it could get away with passing sizeof(struct sockaddr_storage) rather than the actual addrlen previously returned by getaddrinfo(). While that appears to work on many platforms, it does not work on FreeBSD 11: you get back a failure, which leads to the view showing NULL for the address and netmask columns in all rows. The POSIX spec for getnameinfo() is pretty clearly on FreeBSD's side here: you should pass the actual address length. So it seems plausible that there are other platforms where this coding also fails, and we just hadn't noticed. Also, IMO the fact that getnameinfo() failure leads to a NULL output is pretty bogus in itself. Our pg_getnameinfo_all() wrapper is careful to emit "???" on failure, and we should use that in such cases. NULL should only be emitted in rows that don't have IP addresses. Per bug #16695 from Peter Vandivier. Back-patch to v10 where this code was added. Discussion: https://postgr.es/m/16695-a665558e2f630be7@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a58a631b4af0c027c07ea7cc4110a60b5f279ddf Modified Files -------------- src/backend/libpq/hba.c | 31 +++++++++++++++++++++---------- src/include/libpq/hba.h | 6 ++++++ 2 files changed, 27 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-11-03 02:12 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-11-03 02:12 pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. Tom Lane <tgl@sss.pgh.pa.us> 2020-11-03 02:12 pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. Tom Lane <tgl@sss.pgh.pa.us> 2020-11-03 02:12 pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. Tom Lane <tgl@sss.pgh.pa.us> 2020-11-03 02:12 pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. Tom Lane <tgl@sss.pgh.pa.us> 2020-11-03 02:12 pgsql: Fix unportable use of getnameinfo() in pg_hba_file_rules view. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox