pgsql: Avoid calling memcpy() with a NULL source pointer and count == 0

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid calling memcpy() with a NULL source pointer and count == 0
Date: 2015-08-02 19:48:57
Message-ID: E1ZLzFh-0008Jh-QB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid calling memcpy() with a NULL source pointer and count == 0.

As in commit 0a52d378b03b7d5a, avoid doing something that has undefined
results according to the C standard, even though in practice there does
not seem to be any problem with it.

This fixes two places in numeric.c that demonstrably could call memcpy()
with such arguments. I looked through that file and didn't see any other
places with similar hazards; this is not to claim that there are not such
places in other files.

Per report from Piotr Stefaniak. Back-patch to 9.5 which is where the
previous commit was added. We're more or less setting a precedent that
we will not worry about this type of issue in pre-9.5 branches unless
someone demonstrates a problem in the field.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/c75b1f75b3d159c0e71c1ec7f42c922bce448d89

Modified Files
--------------
src/backend/utils/adt/numeric.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2015-08-02 19:53:49 Re: Taint mode in PL/Perl
Previous Message Heikki Linnakangas 2015-08-02 19:17:16 pgsql: Fix output of ISBN-13 numbers beginning with 979.