pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: operationsengineer1@yahoo.com
Cc: Ed Finkler <coj@cerias.purdue.edu>
Cc: Volkan YAZICI <volkan.yazici@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Effectiveness of pg_escape_string at blocking SQL injection
Date: Fri, 27 May 2005 13:13:41 -0500
Message-ID: <20050527181341.GA9856@wolff.to> (raw)
In-Reply-To: <20050527172552.50460.qmail@web52409.mail.yahoo.com>
References: <20050527172552.50460.qmail@web52409.mail.yahoo.com>

On Fri, May 27, 2005 at 10:25:52 -0700,
  operationsengineer1@yahoo.com wrote:
> 
> bruno and all...  what are bind parameters?  how can i
> avoid building sql from user input when my sql depends
> on user input?

You leave place holders in the SQL string to be replaced by parameters
passed separately. You don't need to do any escaping of the parameters
when passed this way.

Here is a snipet of perl code that does this:
    $rows = $dbh->do(<<'EOF',
INSERT INTO detail (day, amount, comment, category, cat_type)
  SELECT ?, ?, ?, id, cat_type FROM category WHERE id = ?
EOF
      {}, param('day'), param('amount'), param('comment'), param('category'));



view thread (9+ messages)  latest in thread

Message-ID: <20050527181341.GA9856@wolff.to>
Permalink:  ../20050527181341.GA9856@wolff.to/
Also on:    postgresql.org/message-id/20050527181341.GA9856@wolff.to

 · 

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-php@postgresql.org
  Cc: bruno@wolff.to, operationsengineer1@yahoo.com, coj@cerias.purdue.edu, volkan.yazici@gmail.com
  Subject: Re: Effectiveness of pg_escape_string at blocking SQL injection
  In-Reply-To: <20050527181341.GA9856@wolff.to>
  References: <20050527172552.50460.qmail@web52409.mail.yahoo.com> <20050527181341.GA9856@wolff.to>

* 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