aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2016-06-24 08:11:34 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2016-07-05 17:21:59 +0200
commitd54553799867c2fe8ac2f21ff92e53430ccdd6ce (patch)
treebd8e2e581c84a5a5ea0dbcb495249099dcb9424b
parent9b0418d2c465b8e4c9d6cc1c7e763da478fd0925 (diff)
downloadWebsocket-d54553799867c2fe8ac2f21ff92e53430ccdd6ce.zip
Websocket-d54553799867c2fe8ac2f21ff92e53430ccdd6ce.tar.gz
Websocket-d54553799867c2fe8ac2f21ff92e53430ccdd6ce.tar.bz2
Protocol: Read the whole frame when length is zero.
When the length of the message is zero, the `readFrame` method returns earlier. However, if a masking key is present in the frame, it is not read and then still present in the buffer. So the next `readFrame` calls will be invalidated. To avoid that, the masking key is read, so the whole frame, each time the `readFrame` method is called.
-rw-r--r--Protocol/Rfc6455.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/Protocol/Rfc6455.php b/Protocol/Rfc6455.php
index 2182bb1..13994e3 100644
--- a/Protocol/Rfc6455.php
+++ b/Protocol/Rfc6455.php
@@ -153,6 +153,11 @@ class Rfc6455 extends Generic
if (0 === $length) {
$out['message'] = '';
+ // Consume the whole frame.
+ if (0x1 === $out['mask']) {
+ $connection->read(4);
+ }
+
return $out;
} elseif (0x7e === $length) {
$handle = unpack('nl', $connection->read(2));