Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done
Date: 2015-02-03 07:28:10
Message-ID: CAB7nPqSnZMiRMZ_HJ2XLm2i9jcs3SPRJ-8hBmG0f24OjHcyc+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

In ecpg_add_mem of memory.c, we use ecpg_alloc but there is actually
no NULL-pointer check. If an OOM shows up exactly at this point, this
is likely to cause a crash. Attached patch adds some extra processing
to ecpg_add_mem to check if the allocation fails, and to fail properly
if an OOM appears.
This issue has been pointed out by Coverity, and I guessed the legwork
needed by myself.
Regards,
--
Michael

Attachment Content-Type Size
20150203_ecpg_fix_dereferenced.patch application/x-patch 3.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen R. van den Berg 2015-02-03 07:43:29 Table description in the data file (Re: pg_rawdump)
Previous Message Heikki Linnakangas 2015-02-03 07:25:35 Re: Missing markup in pg_receivexlog.sgml