Re: fix ecpg core dump when there's a very long struct variable name in .pgc file

Lists: pgsql-hackers
From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-22 10:09:20
Message-ID: 50ADF9D0.6020405@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

hi

I found a small bug in ecpg command and try to fix it.
Please check if it is correct.

When use a struct variable whose name length is very very long such as 12KB in .pgc source,
ecpg will core dump because of buffer overflow if precompile the .pgc file.

$ ecpg testLongStructName.pgc
Segmentation fault (core dumped)

Normally no body will write a variable with so long name,
but whether it's better to fix it.

Best Regards,
Chen Huajun

Attachment Content-Type Size
ecpg_LongStrucNameDump_fix.diff text/plain 778 bytes
testLongStructName12K.zip application/x-zip-compressed 825 bytes

From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-22 10:50:30
Message-ID: 50AE0376.6020009@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


sorry,There's a miss(with out free memory) in that patch sended just now,
and resend it.

Best Regards,
Chen Huajun

(2012/11/22 18:09), Chen Huajun wrote:
> hi
>
> I found a small bug in ecpg command and try to fix it.
> Please check if it is correct.
>
> When use a struct variable whose name length is very very long such as 12KB in .pgc source,
> ecpg will core dump because of buffer overflow if precompile the .pgc file.
>
> $ ecpg testLongStructName.pgc
> Segmentation fault (core dumped)
>
>
> Normally no body will write a variable with so long name,
> but whether it's better to fix it.
>
>
> Best Regards,
> Chen Huajun
>
>
>
>

--
Best Regards
--------------------------------------------------
富士通南大軟件技術有限公司(FNST)
第二ソフトウェア事業部第三開発部
陳華軍(チン カグン)
Addr: 南京富士通南大軟件技術有限公司(FNST)
中国南京市雨花台区文竹路6号(210012)
Mail: chenhj(at)cn(dot)fujitsu(dot)com
Tel : +86+25-86630566-8406 内線: 7998-8406
Fax : +86+25-83317685
--------------------------------------------------

Attachment Content-Type Size
ecpg_LongStrucNameDump_fix.diff text/plain 1008 bytes

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-23 13:42:48
Message-ID: 20121123134248.GA32440@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 22, 2012 at 06:09:20PM +0800, Chen Huajun wrote:
> When use a struct variable whose name length is very very long such as 12KB in .pgc source,
> ecpg will core dump because of buffer overflow if precompile the .pgc file.

How on earth did you run into this? :)

I absolutely agree that this is better be fixed and cjust committed the second
version of your patch.

Thanks.

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


From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-25 12:02:33
Message-ID: 50B208D9.4060106@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> How on earth did you run into this? :)

ooh, first I saw the code accidentally,it looks a bit dangerous and differents from the function ECPGdump_a_simple() above,
And then I tried to write a test to raise some errors.

Thanks for your comment,I will add the patch into commitfest later.
It maybe my first patch for open source.
And I am glad if I can do more for PostgreSQL which is so fine.:)

Regards,
Chen Huajun
(2012/11/23 21:42), Michael Meskes wrote:
> On Thu, Nov 22, 2012 at 06:09:20PM +0800, Chen Huajun wrote:
>> When use a struct variable whose name length is very very long such as 12KB in .pgc source,
>> ecpg will core dump because of buffer overflow if precompile the .pgc file.
>
> How on earth did you run into this? :)
>
> I absolutely agree that this is better be fixed and cjust committed the second
> version of your patch.
>
> Thanks.
>
> Michael


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-25 14:18:24
Message-ID: 20121125141824.GA6151@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Nov 25, 2012 at 08:02:33PM +0800, Chen Huajun wrote:
> Thanks for your comment,I will add the patch into commitfest later.

No need for that, the patch is already committed to the archive.

> It maybe my first patch for open source.

It definitely is then.

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


From: Chen Huajun <chenhj(at)cn(dot)fujitsu(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: fix ecpg core dump when there's a very long struct variable name in .pgc file
Date: 2012-11-26 06:04:05
Message-ID: 50B30655.9050400@cn.fujitsu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

(2012/11/25 22:18), Michael Meskes wrote:
> On Sun, Nov 25, 2012 at 08:02:33PM +0800, Chen Huajun wrote:
>> Thanks for your comment,I will add the patch into commitfest later.
>
> No need for that, the patch is already committed to the archive.

Oh,I got it,Thanks!

--
Regards,
Chen Huajun