Re: Returning non-terminated string in ECPG Informix-compatible function - Mailing list pgsql-hackers

From Oleg Tselebrovskiy
Subject Re: Returning non-terminated string in ECPG Informix-compatible function
Date
Msg-id 9e6bd5d519c312ffdfa9a3c39b95910f@postgrespro.ru
Whole thread Raw
In response to Re: Returning non-terminated string in ECPG Informix-compatible function  (Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>)
Responses Re: Returning non-terminated string in ECPG Informix-compatible function
List 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

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Fix race condition in InvalidatePossiblyObsoleteSlot()
Next
From: vignesh C
Date:
Subject: Re: Why is subscription/t/031_column_list.pl failing so much?