pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Simonetti <marks@opalsoftware.co.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: pgxml bug (crash) in xslt_proc.c
Date: Sat, 11 Oct 2014 18:08:35 +0100
Message-ID: <54396413.8070808@opalsoftware.co.uk> (raw)
In-Reply-To: <26324.1413045568@sss.pgh.pa.us>
References: <543920CE.9090505@opalsoftware.co.uk>
	<24870.1413041595@sss.pgh.pa.us>
	<5439523F.8030500@opalsoftware.co.uk>
	<26324.1413045568@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 11/10/2014 17:39, Tom Lane wrote:
> Mark Simonetti <marks@opalsoftware.co.uk> writes:
>> I hadn't really thought of it as a security issue, it came about from
>> just trying to use it normally while developing software for one of my
>> clients.  At first I found it hard to repeat, but I eventually found a
>> query to repeat the problem 100% of the time. Unfortunately the XML I
>> used to repeat it is vast and generated from lots of database data so it
>> would be hard to submit that as a test case (though I can if it would
>> help by capturing the XML data into a file and sending it along with the
>> XSLT file).
> Well, it would be nice to have a test case ...


No problem, I will sort something out though it might be tomorrow now.


>
>> It seems to be to do with the order in which resources are
>> freed:
>> I changed this (xslt_proc.c, pgxml, postgres 9.3.5, line 167 onwards) : -
>>       xsltFreeStylesheet(stylesheet);
>>       xmlFreeDoc(restree);
>>       xmlFreeDoc(doctree);
>>       xsltFreeSecurityPrefs(xslt_sec_prefs);
>>       xsltFreeTransformContext(xslt_ctxt);  <== crash here
>> To this:
>>       xsltFreeTransformContext(xslt_ctxt);
>>       xsltFreeSecurityPrefs(xslt_sec_prefs);
>>       xsltFreeStylesheet(stylesheet);
>>       xmlFreeDoc(restree);
>>       xmlFreeDoc(doctree);
>> No more crash.
> ... but this seems like a pretty straightforward change: probably the
> problem is that the xslt_ctxt has a dangling pointer to the
> xslt_sec_prefs, stylesheet, or doctree.


Yes I thought the same once I found where the problem was it seemed 
fairly trivial; finding it wasn't quite so straightforward admittedly!  
I'm almost certain it is doctree; xslt_sec_prefs is not touched in the 
transformation context free function and stylesheet is never associated 
with it (though I suppose it could be indirectly).  I'm just glad I 
found it and can use this build of PostgreSQL for now as the people I'm 
working for are a rather large client and they want to see it working.  
This is the great thing about open source though.


>
> Actually it seems to me the most sensible thing would be to free these
> various objects in reverse order of creation, which would mean that it
> ought to be
>
>        xmlFreeDoc(restree);
>        xsltFreeTransformContext(xslt_ctxt);
>        xsltFreeSecurityPrefs(xslt_sec_prefs);
>        xsltFreeStylesheet(stylesheet);
>        xmlFreeDoc(doctree);
>
> Would you try that on your test case and see if it's OK?


Yep no problem, I will try that tomorrow.


Regards,
Mark.
--



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (6+ messages)

Message-ID: <54396413.8070808@opalsoftware.co.uk>
Permalink:  ../54396413.8070808@opalsoftware.co.uk/
Also on:    postgresql.org/message-id/54396413.8070808@opalsoftware.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: marks@opalsoftware.co.uk, tgl@sss.pgh.pa.us
  Subject: Re: pgxml bug (crash) in xslt_proc.c
  In-Reply-To: <54396413.8070808@opalsoftware.co.uk>
  References: <543920CE.9090505@opalsoftware.co.uk> <24870.1413041595@sss.pgh.pa.us> <5439523F.8030500@opalsoftware.co.uk> <26324.1413045568@sss.pgh.pa.us> <54396413.8070808@opalsoftware.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox