Re: [HACKERS] 【ECPG】strncpy function does not set the end character '\0' - Mailing list pgsql-hackers

From Michael Meskes
Subject Re: [HACKERS] 【ECPG】strncpy function does not set the end character '\0'
Date
Msg-id 1504683719.2640.84.camel@postgresql.org
Whole thread Raw
In response to [HACKERS] 【ECPG】strncpy function does not set the end character '\0'  ("postgresql_2016@163.com" <postgresql_2016@163.com>)
Responses Re: [HACKERS] 【ECPG】strncpy function does not set the end character '\0'
List pgsql-hackers
> When we reviewed the ecpg code,we found the array seem not have the
> end
> character('\0')  after using the strncpy function. 

True.

> In the function ECPGnoticeReceiver, we use the stncpy function copy
> the
> sqlstate to sqlca->sqlstate. And the  sqlca->sqlstate is defined as
> the size
> of 5, and the copy size is sizeof(sqlca->sqlstate). However, from the
> previous strcmp function, the sqlstate size may be 5,such as
> ECPG_SQLSTATE_INVALID_CURSOR_NAME. So there may be lack of the end
> character
> for sqlca->sqlstate.

Why do you think there should be one? My memory might be wrong but I
don't think it's supposed to be a null terminated string.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] document and use SPI_result_code_string()
Next
From: Haribabu Kommi
Date:
Subject: Re: [HACKERS] VACUUM and ANALYZE disagreeing on what reltuples means