From 36a2d52041cbc1f6ca8e11bf34cd93ca2066ba05 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 10 Jan 2025 13:34:02 -0500 Subject: [PATCH] Ensure server keypair expiration checks handle invalid values --- src/Socialbox/Classes/RpcClient.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Socialbox/Classes/RpcClient.php b/src/Socialbox/Classes/RpcClient.php index 99dc878..f43e5a6 100644 --- a/src/Socialbox/Classes/RpcClient.php +++ b/src/Socialbox/Classes/RpcClient.php @@ -51,7 +51,7 @@ if($exportedSession !== null) { // Check if the server keypair has expired from the exported session - if(time() > $exportedSession->getServerKeypairExpires()) + if($exportedSession->getServerKeypairExpires() > 0 && time() > $exportedSession->getServerKeypairExpires()) { throw new RpcException('The server keypair has expired, a new session must be created'); } @@ -71,7 +71,7 @@ $this->serverInformation = self::getServerInformation(); // Check if the active keypair has expired - if(time() > $this->serverInformation->getServerKeypairExpires()) + if($this->serverInformation->getServerKeypairExpires() > 0 && time() > $this->serverInformation->getServerKeypairExpires()) { throw new RpcException('The server keypair has expired but the server has not provided a new keypair, contact the server administrator'); } @@ -110,7 +110,7 @@ $this->serverInformation = self::getServerInformation(); // Check if the server keypair has expired - if(time() > $this->serverInformation->getServerKeypairExpires()) + if($this->serverInformation->getServerKeypairExpires() > 0 && time() > $this->serverInformation->getServerKeypairExpires()) { throw new RpcException('The server keypair has expired but the server has not provided a new keypair, contact the server administrator'); } @@ -500,14 +500,6 @@ { throw new RpcException(sprintf('Failed to get server information at %s, server responded with ' . $responseCode, $this->rpcEndpoint)); } - - throw new RpcException(sprintf('Failed to get server information at %s, server responded with ' . $responseCode . ': ' . $response, $this->rpcEndpoint)); - } - - if(empty($response)) - { - curl_close($ch); - throw new RpcException(sprintf('Failed to get server information at %s, server returned an empty response', $this->rpcEndpoint)); } curl_close($ch);