Lists: | pgsql-hackers |
---|
From: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
---|---|
To: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | another ecpg crash |
Date: | 2008-05-11 04:50:22 |
Message-ID: | 48267B0E.1000005@timbira.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
I found another bug when using 'exec sql include filename'. If you use a
filename that doesn't exist, ecpg crashes while trying to close a null
pointer. The above test case shows it. A possible fix is attached.
#include <stdio.h>
/* foo.h doesn't exist */
exec sql include foo;
int main(void)
{
return 0;
}
(gdb) bt
#0 0xb7a746fd in fclose@@GLIBC_2.1 () from /lib/libc.so.6
#1 0x080496e1 in mmerror (error_code=2, type=ET_FATAL, error=0xb7eeb0cc
<Address 0xb7eeb0cc out of bounds>)
at /a/pgsql/dev/pgsql/src/interfaces/ecpg/preproc/preproc.y:93
#2 0x08069d07 in parse_include () at
/a/pgsql/dev/pgsql/src/interfaces/ecpg/preproc/pgc.l:1270
#3 0x08067fa7 in base_yylex () at
/a/pgsql/dev/pgsql/src/interfaces/ecpg/preproc/pgc.l:1080
#4 0x0806d4ce in filtered_base_yylex () at
/a/pgsql/dev/pgsql/src/interfaces/ecpg/preproc/parser.c:64
#5 0x0804a8a8 in base_yyparse () at y.tab.c:20322
#6 0x0806ca35 in main (argc=2, argv=0xbff0ea94) at
/a/pgsql/dev/pgsql/src/interfaces/ecpg/preproc/ecpg.c:462
(gdb) print yyin
$1 = (FILE *) 0x0
--
Euler Taveira de Oliveira
http://www.timbira.com/
Attachment | Content-Type | Size |
---|---|---|
crash2.diff | text/x-patch | 826 bytes |
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | Re: another ecpg crash |
Date: | 2008-05-11 04:52:51 |
Message-ID: | 20080511045251.GD9136@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Euler Taveira de Oliveira wrote:
> Hi,
>
> I found another bug when using 'exec sql include filename'. If you use a
> filename that doesn't exist, ecpg crashes while trying to close a null
> pointer. The above test case shows it. A possible fix is attached.
Huh, isn't the test backwards?
> --- 90,98 ----
> ret_value = error_code;
> break;
> case ET_FATAL:
> ! /* there are some cases (i.e. file not found) that the input is not available */
> ! if (!yyin)
> ! fclose(yyin);
> fclose(yyout);
> if (unlink(output_filename) != 0 && *output_filename != '-')
> fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
From: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | Re: another ecpg crash |
Date: | 2008-05-11 05:19:05 |
Message-ID: | 482681C9.1010502@timbira.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Alvaro Herrera wrote:
> Huh, isn't the test backwards?
>
In which way? I use a simple one but whatever test that uses 'exec sql
include foo' and foo.h doesn't exist, it will crash.
--
Euler Taveira de Oliveira
http://www.timbira.com/
From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | Re: another ecpg crash |
Date: | 2008-05-11 09:12:52 |
Message-ID: | 20080511091252.GA14240@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sun, May 11, 2008 at 02:19:05AM -0300, Euler Taveira de Oliveira wrote:
> Alvaro Herrera wrote:
>
> >Huh, isn't the test backwards?
> >
> In which way? I use a simple one but whatever test that uses 'exec sql
> include foo' and foo.h doesn't exist, it will crash.
I think he means specifically this line in the diff:
> ! /* there are some cases (i.e. file not found)
> ! * that the input is not available */
> ! if (!yyin)
> ! fclose(yyin);
This will close the file *only* if yyin is NULL, which probably isn't
what is meant.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.
From: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
---|---|
To: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
Cc: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | Re: another ecpg crash |
Date: | 2008-05-12 03:43:14 |
Message-ID: | 4827BCD2.2060808@timbira.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Martijn van Oosterhout wrote:
> This will close the file *only* if yyin is NULL, which probably isn't
> what is meant.
>
Ops... you're right. :-)
--
Euler Taveira de Oliveira
http://www.timbira.com/
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Euler Taveira de Oliveira <euler(at)timbira(dot)com> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, meskes(at)postgresql(dot)org |
Subject: | Re: another ecpg crash |
Date: | 2008-05-12 16:33:23 |
Message-ID: | 20080512163323.GB2143@feivel.credativ.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sun, May 11, 2008 at 01:50:22AM -0300, Euler Taveira de Oliveira wrote:
> I found another bug when using 'exec sql include filename'. If you use a
> filename that doesn't exist, ecpg crashes while trying to close a null
> pointer. The above test case shows it. A possible fix is attached.
Thanks again, I just committed the fix.
Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!