Skip to content

Commit

Permalink
Merge pull request #6562 from marc1706/ticket/14047
Browse files Browse the repository at this point in the history
[ticket/14047] Check for stream close handshake before closing stream
  • Loading branch information
marc1706 committed Nov 5, 2023
2 parents f6b4c5b + 0e1e792 commit 43e69df
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions phpBB/includes/functions_jabber.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ class jabber

var $features = array();

/** @var string Stream close handshake */
private const STREAM_CLOSE_HANDSHAKE = '</stream:stream>';

/**
* Constructor
*
* @param string $server Jabber server
* @param int $port Jabber server port
* @param string $username Jabber username or JID
* @param string $password Jabber password
* @param boold $use_ssl Use ssl
* @param bool $use_ssl Use ssl
* @param bool $verify_peer Verify SSL certificate
* @param bool $verify_peer_name Verify Jabber peer name
* @param bool $allow_self_signed Allow self signed certificates
Expand Down Expand Up @@ -183,7 +186,15 @@ function disconnect()
$this->send_presence('offline', '', true);
}

$this->send('</stream:stream>');
$this->send(self::STREAM_CLOSE_HANDSHAKE);
// Check stream close handshake reply
$stream_close_reply = $this->listen();

if ($stream_close_reply != self::STREAM_CLOSE_HANDSHAKE)
{
$this->add_to_log("Error: Unexpected stream close handshake reply ”{$stream_close_reply}");
}

$this->session = array();
return fclose($this->connection);
}
Expand Down

0 comments on commit 43e69df

Please sign in to comment.