Re: non-standard escapes in string literals

From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: non-standard escapes in string literals
Date: 2002-06-05 04:20:08
Message-ID: 5.1.0.14.1.20020605114014.02dc4af0@192.228.128.13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 09:58 PM 6/4/02 +0200, Peter Eisentraut wrote:
>Lincoln Yeoh writes:
>
> > But for the ANSI standard how does one stuff \r\n\t and other control
> > characters into the database?
> >
> > If there's no way other than actually sending the control characters then
> > that is a bad idea especially from a security viewpoint.
>
>Why??

Quoting is to help separate data from commands. Though '' is sufficient for
quoting ' it seems to me not sufficient for control characters.

There could be control characters that cause problems with the DB, and
people may not be sufficiently aware of potential problems. If you just
remove the problematic characters, it means you can't store them in the
database - the db can become less useful.

Whereas with the current way of quoting control characters, if you are
unsure what to quote, you could safely quote every "untrusted" character.
Less chance of things going wrong. Also being able to quote allows you to
store control characters in the database.

An example of what could go wrong: a RDBMS may treat raw backspaces as part
of the command stream and not the data, and thus

insert into pics (data) values ('$CGIPARAM')
could become -
insert into pics (data) values('....JFIF^H^H^H^H^H^H...^H^H^HUPDATE row
from IMPORTANT where (rowid='1')
Which is treated as
UPDATE row from IMPORTANT where (rowid='1')

And so a file upload becomes an insiduous alteration of important data.

Hope that helps,
Link.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Lincoln Yeoh 2002-06-05 04:27:25 Re: non-standard escapes in string literals
Previous Message Oliver Elphick 2002-06-04 21:34:38 [Fwd: Bug#149056: postgresql: should not try in a busy loop when allocating resources]