Re: Returning non-terminated string in ECPG Informix-compatible function

From: Oleg Tselebrovskiy <o(dot)tselebrovskiy(at)postgrespro(dot)ru>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Returning non-terminated string in ECPG Informix-compatible function
Date: 2024-02-15 05:15:40
Message-ID: 9e6bd5d519c312ffdfa9a3c39b95910f@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greetings again.
I was looking through more static analyzer output and found another
problem.
In ecpg/pgtypeslib/dt_common.c there are 4 calls of pgtypes_alloc.
This function uses calloc and returns NULL if OOM, but we don't check
its
return value and immediately pass it to strcpy, which could lead to
segfault.

I suggest adding a check for a return value since all other calls of
pgtypes_alloc are checked for NULL.

A proposed patch (with previous and current changes) is attached

Oleg Tselebrovskiy, Postgres Pro

Attachment Content-Type Size
ecpg_bugfixes.patch text/x-diff 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-02-15 05:16:11 Re: Why is subscription/t/031_column_list.pl failing so much?
Previous Message Michael Paquier 2024-02-15 05:09:45 Re: Fix race condition in InvalidatePossiblyObsoleteSlot()