pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: chenhj <chjischj@163.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12917: C program created by ecpg core dumped due to "varcharsize * offset"
Date: Tue, 07 Apr 2015 16:15:51 +0800
Message-ID: <1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com> (raw)
In-Reply-To: <CAB7nPqT4fTkN5+fG08h2i_f308BsZdu8rWZnJQ+ET2m9rb6WVw@mail.gmail.com>
References: <20150330111334.2492.38927@wrigleys.postgresql.org>
	<CAB7nPqT4fTkN5+fG08h2i_f308BsZdu8rWZnJQ+ET2m9rb6WVw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 2015-04-06 10:23 , Michael Paquier Wrote: And this test expects that result of column "name" does not contain more 10k characters, so your data set is incompatible with your test, explaining the crash you are seeing. -- Michael --------------- Thanks for your answer,but i still can not understand why here is "varcharsize * offset >= size", while in the non binary branch that is "varcharsize >= size" and works fine on the same test case(truncate size to varcharsize).  binary.pgc:  ----------------------   EXEC SQL DECLARE B BINARY CURSOR FOR select name from empl where idnum =:empl.idnum;  ==>(the non binary branch works fine)   EXEC SQL DECLARE B CURSOR FOR select name from empl where idnum =:empl.idnum;  src/interfaces/ecpg/ecpglib/data.c:466  if (binary)  {       if (varcharsize == 0 || varcharsize * offset >= size)            memcpy(var + offset * act_tuple, pval, size);//!!! memory overflow for BINARY CURSOR !!!       else       {            memcpy(var + offset * act_tuple, pval, varcharsize * offset);         ...         }  ...  }  else  {  ...       if (varcharsize == 0 || varcharsize > size)       {            strncpy(str, pval, size + 1);       ...       }       else       {            strncpy(str, pval, varcharsize);//!!! truncate size to varcharsize for NON BINARY CURSOR !!!       ...       }  ...  --  Regards, Chen Huajun

view thread (3+ messages)

Message-ID: <1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com>
Permalink:  ../1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com/
Also on:    postgresql.org/message-id/1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: chjischj@163.com, michael.paquier@gmail.com
  Subject: Re: BUG #12917: C program created by ecpg core dumped due to "varcharsize * offset"
  In-Reply-To: <1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com>
  References: <20150330111334.2492.38927@wrigleys.postgresql.org> <CAB7nPqT4fTkN5+fG08h2i_f308BsZdu8rWZnJQ+ET2m9rb6WVw@mail.gmail.com> <1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox