Re: Small fix: avoid passing null pointers to memcpy()

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small fix: avoid passing null pointers to memcpy()
Date: 2016-08-03 22:32:50
Message-ID: 5b82e950-a827-901e-7ae8-0e11e6c9830d@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4/16/16 8:48 AM, Piotr Stefaniak wrote:
> On 2016-04-03 09:24, Piotr Stefaniak wrote:
>> > from running the regression test suite (including TAP tests) and also
>> > sqlsmith, I've got a couple of places where UBSan reported calls to
>> > memcpy() with null pointer passed as either source or destination.
>> >
>> > Patch attached.
> Patch updated.
>
> Since this time the patch includes fixes for other standard library
> function calls (memset and bsearch), I'm renaming the patch file to be
> more generic.

Most of these changes appear to address the case where the size argument
of memcpy() is zero. I'm not sure why those changes are necessary. At
least in some cases that I sporadically checked, a zero size does not
lead to a null pointer argument. We'll need some more details here.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2016-08-03 23:28:52 Re: Lossy Index Tuple Enhancement (LITE)
Previous Message Álvaro Hernández Tortosa 2016-08-03 22:31:13 Re: Implementing full UTF-8 support (aka supporting 0x00)