Returning non-terminated string in ECPG Informix-compatible function

From: o(dot)tselebrovskiy(at)postgrespro(dot)ru
To: pgsql-hackers(at)postgresql(dot)org
Subject: Returning non-terminated string in ECPG Informix-compatible function
Date: 2024-01-29 08:47:31
Message-ID: bf47888585149f83b276861a1662f7e4@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greetings, everyone!

While analyzing output of Svace static analyzer [1] I've found a bug.

In function intoasc(interval * i, char *str) from file
src/interfaces/ecpg/compatlib/informix.c
we return a non-terminated string since we use memcpy on tmp which is
itself NULL-teminated but
last zero byte is not copied.

The proposed solution is to use strcpy instead, since it is used in all
other functions in informix.c.

The patch is attached.

[1] - https://svace.pages.ispras.ru/svace-website/en/

Oleg Tselebrovskiy, Postgres Pro

Attachment Content-Type Size
informix_null_terminator.patch text/x-diff 395 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-01-29 08:52:14 Re: Synchronizing slots from primary to standby
Previous Message Yugo NAGATA 2024-01-29 08:28:58 Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row