pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ryan Kelly <rpkelly22@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: hstore parser incorrectly handles malformed input
Date: Thu, 26 Apr 2012 15:05:13 -0400
Message-ID: <20120426190513.GB31886@llserver.lakeliving.com> (raw)

It seems that the hstore parser has some odd behavior in the the
handling of certain malformed input constructions:

[db]> select 'a=>,b=>1'::hstore;
    hstore    
--------------
 "a"=>",b=>1"

[db]> select 'a=> ,b=>1'::hstore;
    hstore    
--------------
 "a"=>",b=>1"

[db]> select 'a=>, b=>1'::hstore;
ERROR:  Syntax error near 'b' at position 5
LINE 2: select 'a=>, b=>1'::hstore;

In my mind, all of these should have been rejected as erroneous input.
To that end, I have attached a patch which causes all of these inputs
to be rejected as invalid.

-Ryan Kelly

Attachments:

hstore-parser.patch (text/x-diff, 581B) download diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index 0eb48cf..13d6c22 100644 --- a/contrib/hstore/hstore_io.c +++ b/contrib/hstore/hstore_io.c @@ -76,6 +76,10 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped) { elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin)); } + else if (*(state->ptr) == ',') + { + elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin)); + } else if (*(state->ptr) == '\\') { st = GV_WAITESCIN;

view thread (9+ messages)  latest in thread

Message-ID: <20120426190513.GB31886@llserver.lakeliving.com>
Permalink:  ../20120426190513.GB31886@llserver.lakeliving.com/
Also on:    postgresql.org/message-id/20120426190513.GB31886@llserver.lakeliving.com

 ·  · 

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: rpkelly22@gmail.com
  Subject: Re: hstore parser incorrectly handles malformed input
  In-Reply-To: <20120426190513.GB31886@llserver.lakeliving.com>
  References: <20120426190513.GB31886@llserver.lakeliving.com>

* 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