1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Fix PHP 8.1 "strlen(null)" exception in PhutilOpaqueEnvelope.php

Summary:
This change fixes a RuntimeException for passing null to strlen() when setting up the DB host parameter

Closes T15260

Test Plan: I was able to run "./bin/config set mysql.host "localhost"" successfully

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: Ekubischta, goddenrich, Dylsss, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15260

Differential Revision: https://we.phorge.it/D25129
This commit is contained in:
Andre Klapper 2023-04-25 15:39:38 +02:00
parent ca5f5cd152
commit 82d1abd4ed

View file

@ -60,11 +60,13 @@ final class PhutilOpaqueEnvelope extends Phobject {
*/ */
private function mask($string, $noise) { private function mask($string, $noise) {
$result = ''; $result = '';
for ($ii = 0; $ii < strlen($string); $ii++) { if (phutil_nonempty_string($string)) {
$s = $string[$ii]; for ($ii = 0; $ii < strlen($string); $ii++) {
$n = $noise[$ii % strlen($noise)]; $s = $string[$ii];
$n = $noise[$ii % strlen($noise)];
$result .= chr(ord($s) ^ ord($n)); $result .= chr(ord($s) ^ ord($n));
}
} }
return $result; return $result;
} }