summaryrefslogtreecommitdiffstats
path: root/etc/inc/crypt.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2012-04-30 10:07:29 -0400
committerjim-p <jimp@pfsense.org>2012-04-30 10:08:56 -0400
commit15855fbc5bb1c59bf9efc5221df2fb051a9d27c9 (patch)
tree3ebd5b7f063bf5803975ec64f16426ad64514893 /etc/inc/crypt.inc
parent3f76f90e659a71fb80cecf05c0025e77bf89ad63 (diff)
downloadpfsense-15855fbc5bb1c59bf9efc5221df2fb051a9d27c9.zip
pfsense-15855fbc5bb1c59bf9efc5221df2fb051a9d27c9.tar.gz
Better error handling for crypt_data and also better password argument handling
Diffstat (limited to 'etc/inc/crypt.inc')
-rw-r--r--etc/inc/crypt.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/etc/inc/crypt.inc b/etc/inc/crypt.inc
index 582a84c..8515c84 100644
--- a/etc/inc/crypt.inc
+++ b/etc/inc/crypt.inc
@@ -35,11 +35,16 @@
function crypt_data($val, $pass, $opt) {
$file = tempnam("/tmp", "php-encrypt");
file_put_contents("{$file}.dec", $val);
- exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in {$file}.dec -out {$file}.enc -k {$pass}");
- $result = file_get_contents("{$file}.enc");
- unlink($file);
- unlink("{$file}.dec");
- unlink("{$file}.enc");
+ exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in {$file}.dec -out {$file}.enc -k " . escapeshellarg($pass));
+ if (file_exists("{$file}.enc"))
+ $result = file_get_contents("{$file}.enc");
+ else {
+ $result = "";
+ log_error("Failed to encrypt/decrypt data!");
+ }
+ @unlink($file);
+ @unlink("{$file}.dec");
+ @unlink("{$file}.enc");
return $result;
}
OpenPOWER on IntegriCloud