summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-06-03 17:36:36 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-06-03 17:36:36 +1000
commit6ce881284330487fe3dff3cf740f6befc49914de (patch)
tree53985d09464f740fcb67ecb7b64292aa9c660d34
parent399a5ab5d10d7db4083c4af62326f3f4e6c97280 (diff)
safer IP address decryption (KU_RANDOMSEED)
-rwxr-xr-xkusabax.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/kusabax.php b/kusabax.php
index 9f6ea7a5..6b17499a 100755
--- a/kusabax.php
+++ b/kusabax.php
@@ -188,7 +188,14 @@
}
// IP
- $query->bindValue(':ip', md5_decrypt($post['ip'], $kusabaxc['randomseed']), PDO::PARAM_STR);
+ $ip = md5_decrypt($post['ip'], $kusabaxc['randomseed']);
+ if(!preg_match('/^\d+\.\d+\.\d+\.\d+$/', $ip)) {
+ // Invalid IP address. Wrong KU_RANDOMSEED?
+
+ $log[] = 'Invalid IP address returned after decryption. Wrong KU_RANDOMSEED?';
+ $ip = '0.0.0.0'; // just set it to something valid and continue
+ }
+ $query->bindValue(':ip', $ip, PDO::PARAM_STR);
// Time (`timestamp`)
$query->bindValue(':time', $post['timestamp'], PDO::PARAM_INT);