Security Best Practice: typecast?

From: Date: Sun, 01 Apr 2007 04:03:04 +0000
Subject: Security Best Practice: typecast?
Groups: php.general 
Request: Send a blank email to php-general+get-251850@lists.php.net to get a copy of this message
So, after a recent thread on data filtering, I'm wondering... Is this "good enough" in ALL possible Unicode/charset situations: $foo_id = (int) $_POST['foo_id']; $query = "insert into whatever(foo_id) values($foo_id)"; Or is it possible, even theoretically possible, for a sequence of: [-]?[0-9]+ to somehow run afoul of ANY charset? Perhaps more interesting, how about this: $foo = (float) $_POST['foo']; Is there any way for any PHP output from (float), even with decimal overflow/underflow in various databases, for that to "go wrong"? Should one be ultra-conservative and just do: $foo_sql = mysql_real_escape_string($connection); or is that just being silly? -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#251850) next »