pgsql: Fix inappropriate uses of PG_GETARG_UINT32()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix inappropriate uses of PG_GETARG_UINT32()
Date: 2021-12-06 12:47:03
Message-ID: E1muDOZ-0005QX-Uc@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix inappropriate uses of PG_GETARG_UINT32()

The chr() function used PG_GETARG_UINT32() even though the argument is
declared as (signed) integer. As a result, you can pass negative
arguments to this function and it internally interprets them as
positive. Ultimately ends up being harmless, but it seems wrong, so
fix this and rearrange the internal error checking a bit to
accommodate this.

Another case was in the documentation, where example code used
PG_GETARG_UINT32() with an argument declared as signed integer.

Reviewed-by: Nathan Bossart <bossartn(at)amazon(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/7e43869b-d412-8f81-30a3-809783edc9a3%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e9e63b7022ddd0aaaae7cd439daa234cf9e6a21c

Modified Files
--------------
doc/src/sgml/xfunc.sgml | 2 +-
src/backend/utils/adt/oracle_compat.c | 33 ++++++++++++++++++++-------------
2 files changed, 21 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-12-06 18:23:20 pgsql: Account for TOAST data while scheduling parallel dumps.
Previous Message Andrew Dunstan 2021-12-05 16:53:13 pgsql: Silence perl complaint in ssl test