Skip to content
Snippets Groups Projects
Commit 3f01c87b authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Throw an exception on bad input parameters instead of using assert() in...

Throw an exception on bad input parameters instead of using assert() in SimpleSAML_Utils_System::writeFile().
parent 9f3f55f0
Branches
Tags
No related merge requests found
...@@ -99,8 +99,8 @@ class SimpleSAML_Utils_System ...@@ -99,8 +99,8 @@ class SimpleSAML_Utils_System
* @param string $data The data we should write to the file. * @param string $data The data we should write to the file.
* @param int $mode The permissions to apply to the file. Defaults to 0600. * @param int $mode The permissions to apply to the file. Defaults to 0600.
* *
* @throws SimpleSAML_Error_Exception If the file cannot be saved, permissions cannot be changed or it is not * @throws SimpleSAML_Error_Exception If any of the input parameters doesn't have the proper types, or the file
* possible to write to the target file. * cannot be saved, permissions cannot be changed or it is not possible to write to the target file.
* *
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
...@@ -109,9 +109,9 @@ class SimpleSAML_Utils_System ...@@ -109,9 +109,9 @@ class SimpleSAML_Utils_System
*/ */
public static function writeFile($filename, $data, $mode = 0600) public static function writeFile($filename, $data, $mode = 0600)
{ {
assert('is_string($filename)'); if (!is_string($filename) || !is_string($data) || !is_numeric($mode)) {
assert('is_string($data)'); throw new SimpleSAML_Error_Exception('Invalid input parameters');
assert('is_numeric($mode)'); }
$tmpFile = self::getTempDir().DIRECTORY_SEPARATOR.rand(); $tmpFile = self::getTempDir().DIRECTORY_SEPARATOR.rand();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment