From b3ac5ceb387fc96e172129e2388080308dcf71f7 Mon Sep 17 00:00:00 2001 From: Steve Campbell Date: Wed, 5 Jul 2023 09:08:02 +0100 Subject: [PATCH] Fix DifferentialGetCommitMessageConduitAPIMethod execute strlen(null) Summary: When iterating through the fields of a differential commit, the DifferentialGetCommitMessageConduitAPIMethod execute method explicitly allows a value to be either a string or a null. It then calls strlen upon this possibly null value. We could replace the strlen with phutil_nonempty_string, but as the code has already eliminated variable types other than string or null, it is more efficient to explicitly check for null or '' ``` $value === null or $value == '' ``` Fixes T15527 Test Plan: Run ``` arc diff ``` Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15527 Differential Revision: https://we.phorge.it/D25332 --- .../conduit/DifferentialGetCommitMessageConduitAPIMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php index 51225023ff..a4a2ccc85e 100644 --- a/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php @@ -115,7 +115,7 @@ final class DifferentialGetCommitMessageConduitAPIMethod $is_title = ($field_key == $key_title); - if (!strlen($value)) { + if ($value === null || $value === '') { if ($is_template) { $commit_message[] = $label.': '; }