From 4957ab8fbb80ae5a0550c554de4c5dd61dd41d36 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 26 Apr 2018 20:41:06 +0000 Subject: [PATCH] Avoid PHP warning with a missing key --- src/Protocol/Diaspora.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 6f03c0df87..70728a71ba 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -832,6 +832,10 @@ class Diaspora if (isset($parent_author_signature)) { $key = self::key($msg["author"]); + if (empty($key)) { + logger("No key found for parent author ".$msg["author"], LOGGER_DEBUG); + return false; + } if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, "sha256")) { logger("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG); @@ -840,6 +844,10 @@ class Diaspora } $key = self::key($fields->author); + if (empty($key)) { + logger("No key found for author ".$fields->author, LOGGER_DEBUG); + return false; + } if (!Crypto::rsaVerify($signed_data, $author_signature, $key, "sha256")) { logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);