Re: BUG #16695: pg_hba_file_rules NULL address and netmask

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: petervandivier(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16695: pg_hba_file_rules NULL address and netmask
Date: 2020-11-03 01:27:38
Message-ID: 871849.1604366858@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
>> pg_hba_file_rules reports NULL address and netmask values incorrectly on
>> FreeBSD 11 for tested postgres versions 10-13 (at least). e.g.

> So for the archives' sake: what I suppose Peter means is that the addr
> and netmask come out as NULL on every line, even where they should not.
> At least, that's what I've reproduced here on FreeBSD 11.0.

> I traced through this, and the proximate cause seems to be that
> getnameinfo(3) is failing because it is expecting the passed "salen"
> to be exactly the length it is expecting for the given sa_family.
> Which it is not, because alone among our callers of pg_getnameinfo_all(),
> fill_hba_line() thinks it can get away with passing sizeof(struct
> sockaddr_storage) rather than the actual addrlen previously returned by
> getaddrinfo().

The attached seems to fix it for me. (This is against HEAD, but a quick
check suggests it will apply cleanly down to v10.) As I mentioned,
I'm planning to put the new fields at the end of struct HbaLine in
the back branches.

regards, tom lane

Attachment Content-Type Size
fix-bogus-addrlen-in-hba-view.patch text/x-diff 3.1 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-11-03 01:55:54 BUG #16697: timetz regression test seems to have a false failure
Previous Message Dmitry Marakasov 2020-11-03 00:38:35 Re: BUG #16696: Backend crash in llvmjit