From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix cidin() to handle values above 2^31 platform-independently. |
Date: | 2016-10-18 16:25:36 |
Message-ID: | E1bwXCq-0003gJ-06@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix cidin() to handle values above 2^31 platform-independently.
CommandId is declared as uint32, and values up to 4G are indeed legal.
cidout() handles them properly by treating the value as unsigned int.
But cidin() was just using atoi(), which has platform-dependent behavior
for values outside the range of signed int, as reported by Bart Lengkeek
in bug #14379. Use strtoul() instead, as xidin() does.
In passing, make some purely cosmetic changes to make xidin/xidout
look more like cidin/cidout; the former didn't have a monopoly on
best practice IMO.
Neither xidin nor cidin make any attempt to throw error for invalid input.
I didn't change that here, and am not sure it's worth worrying about
since neither is really a user-facing type. The point is just to ensure
that indubitably-valid inputs work as expected.
It's been like this for a long time, so back-patch to all supported
branches.
Report: <20161018152550(dot)1413(dot)6439(at)wrigleys(dot)postgresql(dot)org>
Branch
------
REL9_2_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/eb338c1cd5347b428725c8d7a79769640c2e10d3
Modified Files
--------------
src/backend/utils/adt/xid.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2016-10-18 17:45:34 | pgsql: Fix typo in comment. |
Previous Message | Tom Lane | 2016-10-18 16:25:35 | pgsql: Fix cidin() to handle values above 2^31 platform-independently. |