pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14587: Foreign constraint with newline blows up pg_restore catalogue
3+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2017-03-10 f39ddd8436 4cdd81d901 88f3743cb1 64d132c299 0c0a95c2f8 e6d2ba4195  Sanitize newlines in object names in "pg_restore -l" output.
* BUG #14587: Foreign constraint with newline blows up pg_restore catalogue
@ 2017-03-10 15:53  milos.urbanek@email.cz
  0 siblings, 1 reply; 3+ messages in thread

From: milos.urbanek@email.cz @ 2017-03-10 15:53 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14587
Logged by:          Milos Urbanek
Email address:      milos.urbanek@email.cz
PostgreSQL version: 9.6.2
Operating system:   Windows
Description:        

As repoted in https://trac.osgeo.org/postgis/ticket/3727

If there is some newline in e.g. foreign key contraint, the second command
below fails:

pg_restore -l test.backup > test.backup.lst

pg_restore -L test.backup.lst > test2.out

With error like:

pg_restore: [archiver] could not find entry for ID 6


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


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14587: Foreign constraint with newline blows up pg_restore catalogue
@ 2017-03-10 16:23  Tom Lane <tgl@sss.pgh.pa.us>
  parent: milos.urbanek@email.cz
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2017-03-10 16:23 UTC (permalink / raw)
  To: milos.urbanek@email.cz; +Cc: pgsql-bugs

milos.urbanek@email.cz writes:
> As repoted in https://trac.osgeo.org/postgis/ticket/3727
> If there is some newline in e.g. foreign key contraint, the second command
> below fails:
> pg_restore -l test.backup > test.backup.lst
> pg_restore -L test.backup.lst > test2.out

Hm.  As of a year or two back, we sanitize object names in the comments
printed in the restore script, eg after

d1=# create table p (f1 int primary key);
CREATE TABLE
d1=# create table f (f1 int);
CREATE TABLE
d1=# alter table f add constraint "weird
d1"# name" foreign key (f1) references p;
ALTER TABLE

the dump output will look like

--
-- Name: f weird name; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY f
    ADD CONSTRAINT "weird
name" FOREIGN KEY (f1) REFERENCES p(f1);

However, pg_restore -l didn't get the memo:

;
; Selected TOC Entries:
;
2991; 1262 46745 DATABASE - d1 postgres
3; 2615 2200 SCHEMA - public postgres
2992; 0 0 COMMENT - SCHEMA public postgres
1; 3079 13112 EXTENSION - plpgsql 
2993; 0 0 COMMENT - EXTENSION plpgsql 
195; 1259 46751 TABLE public f postgres
194; 1259 46746 TABLE public p postgres
2986; 0 46751 TABLE DATA public f postgres
2985; 0 46746 TABLE DATA public p postgres
2862; 2606 46750 CONSTRAINT public p p_pkey postgres
2863; 2606 46754 FK CONSTRAINT public f weird
name postgres

and in turn that breaks -L for such cases.  I think we need to transpose
the sanitization to also happen in these code paths.

Perhaps this should have been treated as a security issue, but the
cat's out of the bag now.  I think automated workflows involving -l
are pretty rare anyway.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14587: Foreign constraint with newline blows up pg_restore catalogue
@ 2017-03-10 17:47  Sandro Santilli <strk@kbt.io>
  0 siblings, 0 replies; 3+ messages in thread

From: Sandro Santilli @ 2017-03-10 17:47 UTC (permalink / raw)
  To: pgsql-bugs

On 2017-03-10 16:23:34 Tom Lane wrote:
>
> Perhaps this should have been treated as a security issue, but the
> cat's out of the bag now.  I think automated workflows involving -l
> are pretty rare anyway

PostGIS' upgrade procedure [1],[2] is actually based on pg_restore -l,
so maybe it's not so rare: 

[1] http://postgis.net/docs/manual-2.3/postgis_installation.html#hard_upgrade
[2] https://trac.osgeo.org/postgis/browser/tags/2.3.2/utils/postgis_restore.pl.in#L117

--strk; 

  ()   Free GIS & Flash consultant/developer
  /\   https://strk.kbt.io/services.html


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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-03-10 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 15:53 BUG #14587: Foreign constraint with newline blows up pg_restore catalogue milos.urbanek@email.cz
2017-03-10 16:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-03-10 17:47 Re: BUG #14587: Foreign constraint with newline blows up pg_restore catalogue Sandro Santilli <strk@kbt.io>

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