Re: query_int wrongly parses zero-padded input

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Grujic <marko(dot)grujic(at)enterprisedb(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Manu <manuelreyesbravo(at)gmail(dot)com>
Subject: Re: query_int wrongly parses zero-padded input
Date: 2026-10-20 19:15:57
Message-ID: 1386567.1792523757@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Marko Grujic <marko(dot)grujic(at)enterprisedb(dot)com> writes:
>> Would "endptr == nnn" be more direct here? That checks whether no
>> conversion occurred, as described in the quoted doc.

> Agreed, that would be more direct, with one caveat (which
> admittedly doesn't apply today),
> and that is that the endptr-not-at-NUL-byte variant also safe-guards
> against trailing-junk (which Tom mentioned).

Yeah, so I think it's better to use the "*endptr == '\0'" variant.
There's a pretty fair number of other places in our tree that do it
like that, and the ones that don't are mostly explicitly allowing
trailing text.

Pushed.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-10-20 19:41:46 Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding
Previous Message Alexander Lakhin 2026-10-20 18:59:01 Re: pg_*_advice: tsv load failure, etc.