Re: non-standard escapes in string literals - Mailing list pgsql-hackers

From Lincoln Yeoh
Subject Re: non-standard escapes in string literals
Date
Msg-id 5.1.0.14.1.20020605114014.02dc4af0@192.228.128.13
Whole thread Raw
In response to Re: non-standard escapes in string literals  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
List 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.




pgsql-hackers by date:

Previous
From: Oliver Elphick
Date:
Subject: [Fwd: Bug#149056: postgresql: should not try in a busy loop when allocating resources]
Next
From: Lincoln Yeoh
Date:
Subject: Re: non-standard escapes in string literals