X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4DC13D1D29D for ; Mon, 29 Mar 2004 15:26:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37896-02 for ; Mon, 29 Mar 2004 11:26:56 -0400 (AST) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 32D1FD1EBB8 for ; Mon, 29 Mar 2004 11:26:43 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i2TFQbS11892; Mon, 29 Mar 2004 10:26:37 -0500 (EST) From: Bruce Momjian Message-Id: <200403291526.i2TFQbS11892@candle.pha.pa.us> Subject: Re: ECPG segfault In-Reply-To: To: =?ISO-8859-1?Q?J=FCrgen_Cappel?= Date: Mon, 29 Mar 2004 10:26:37 -0500 (EST) Cc: pgsql-interfaces X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UNKNOWN-8BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/42 X-Sequence-Number: 4821 Michael has fixed this in 7.4.X and CVS HEAD. Thanks. --------------------------------------------------------------------------- Jürgen 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@postgresql.org) > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073