From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Jürgen Cappel <email(at)juergen-cappel(dot)de> |
Cc: | pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: ECPG segfault |
Date: | 2004-03-29 15:26:37 |
Message-ID: | 200403291526.i2TFQbS11892@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Michael has fixed this in 7.4.X and CVS HEAD. Thanks.
---------------------------------------------------------------------------
Jrgen Cappel wrote:
> The code in ecpg/preproc/type.c has a problem when allocating
> memory. I'm referring to the function ECPGdump_a_simple() where
> one of the first actions is allocating memory and assigning it
> to variable "offset". The amount of memory requested depends on
> the size of the variable's name and the length of a fixed string.
> The function has a parameter called "varcharsize" (array size string)
> which is later used in the "case ECPGt_char:" where it is included
> in an sprintf() to fill the allocated memory area. This leads to
> a subsequent segmentation fault if "varcharsize" is not a simple
> integer but maybe a cpp macro of some length, say, 20 bytes. At
> least it *can* lead to a segfault, because you never know how and
> when memory corruption strikes back on you ...
>
> Using my example, things work well when allocating a few bytes more,
> but i would suggest adding a strlen(varcharsize) instead of 1 byte
> for allocation of "offset".
>
> Comments are welcome ! Best regards, J?rgen Cappel
>
> Oh, and btw thanks to valgrind for pointing me to that place :-)
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | yihuey | 2004-03-30 17:28:17 | Compiler 7.4 with--java Error on Redhad AS 2.4.21 |
Previous Message | Michael Meskes | 2004-03-29 15:15:35 | Re: ECPG mass retrieval? |