pgsql: Ensure that snprintf.c's fmtint() doesn't overflow when printing

Started by Andres Freundalmost 8 years ago3 messagescomitters
Jump to latest
#1Andres Freund
andres@anarazel.de

Ensure that snprintf.c's fmtint() doesn't overflow when printing INT64_MIN.

This isn't actually a live bug, as the output happens to be the
same. But it upsets tools like UBSan, which makes it worthwhile to
fix.

As it's an issue without practical consequences, don't backpatch.

Author: Andres Freund
Discussion: /messages/by-id/20180928001121.hhx5n6dsygqxr5wu@alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4868e4468590bc32f9c3afed4ec795d6a7732c9d

Modified Files
--------------
src/port/snprintf.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#1)
Re: pgsql: Ensure that snprintf.c's fmtint() doesn't overflow when printing

Andres Freund <andres@anarazel.de> writes:

Ensure that snprintf.c's fmtint() doesn't overflow when printing INT64_MIN.

Hm, I think you should s/uint64/unsigned long long/ to be consistent
with 595a0eab7.

regards, tom lane

#3Andres Freund
andres@anarazel.de
In reply to: Tom Lane (#2)
Re: pgsql: Ensure that snprintf.c's fmtint() doesn't overflow when printing

Hi,

On 2018-10-03 16:24:23 -0400, Tom Lane wrote:

Andres Freund <andres@anarazel.de> writes:

Ensure that snprintf.c's fmtint() doesn't overflow when printing INT64_MIN.

Hm, I think you should s/uint64/unsigned long long/ to be consistent
with 595a0eab7.

Fair point. Will push once tests finish.

Greetings,

Andres Freund