File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
modules/core/src/Controller
tests/src/SimpleSAML/Utils Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,11 @@ class MyAuth extends \SimpleSAML\Module\core\Auth\UserPassBase
335335 */
336336 private function checkPassword($passwordHash, $password)
337337 {
338- $passwordHash = base64_decode($passwordHash);
338+ $passwordHash = base64_decode($passwordHash, true);
339+ if (empty($passwordHash)) {
340+ throw new \InvalidArgumentException("Password hash is empty or not a valid base64 encoded string.");
341+ }
342+
339343 $digest = substr($passwordHash, 0, 20);
340344 $salt = substr($passwordHash, 20);
341345
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public function postredirect(Request $request): Response
5959 if ($ redirId !== false ) {
6060 $ postId = $ redirId ;
6161 } elseif ($ redirInfo !== false ) {
62- $ encData = base64_decode ($ redirInfo );
62+ $ encData = base64_decode ($ redirInfo, true );
6363
6464 if (empty ($ encData )) {
6565 throw new Error \BadRequest ('Invalid RedirInfo data. ' );
Original file line number Diff line number Diff line change @@ -337,7 +337,12 @@ public function pem2der(string $pem): string
337337 }
338338 unset($ lines [$ last ]);
339339
340- return base64_decode (implode ($ lines ));
340+ $ transform = base64_decode (implode ($ lines ), true );
341+ if (empty ($ transform )) {
342+ throw new InvalidArgumentException ("pem2der: input is empty or not a valid base64 encoded string. " );
343+ }
344+
345+ return $ transform ;
341346 }
342347
343348
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public function testAesDecrypt(): void
120120uR2Yu0r4itInKx91D/l9y/08L5CIQyev9nAr27fh3Sshous4vbXRRcMcjqHDOrquD+2vqLyw7ygnbA9jA9TpB4hLZocvAWcTN8tyO82hiSY=
121121CIPHER ;
122122
123- $ decrypted = $ this ->cryptoUtils ->aesDecrypt (base64_decode ($ ciphertext ));
123+ $ decrypted = $ this ->cryptoUtils ->aesDecrypt (base64_decode ($ ciphertext, true ));
124124 $ this ->assertEquals ($ plaintext , $ decrypted );
125125 }
126126
You can’t perform that action at this time.
0 commit comments