Re: BUG #12917: C program created by ecpg core dumped due to "varcharsize * offset"

From: chenhj <chjischj(at)163(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #12917: C program created by ecpg core dumped due to "varcharsize * offset"
Date: 2015-04-07 08:15:51
Message-ID: 1428394546492.wcm3vrkwsf0dk52q01lyceau@android.mail.163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message kingter wang 2015-04-07 08:34:15 pg_rewind test could not run in 'remote' mode
Previous Message Kingter Wang 2015-04-07 07:22:02 pg_rewind TAP tests won't run in 'remote' mode