Decode broken when multiple calls same time

未关闭
#59 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
php
领域
networking

调研方向

首先定位 issue 中所示的 private 函数 decode($msg),并用快速连续发送的两个帧重现该情况。跟踪消息长度和 payload 边界的处理方式,然后验证这两个帧会产生彼此独立的解码输出。

由索引模型根据 Issue 内容生成。

描述

auto-migrated Priority-Medium Type-Defect
What steps will reproduce the problem?

Send two frames in a very short time
  socket.send('message1')
  socket.send('message2')

As result, the decoding function does not understand when first frame end and 
second one start, which causes it handle two frame as single. This lead broken 
output.

Decode function is:
    private function decode ($msg) {
        $len = $data = $decoded = $index = null;
        $len = $msg[1] & 127;
        if ($len === 126) {
            $this->masks = substr ($msg, 4, 4);
            $data = substr ($msg, 8);
            $this->initFrame = substr ($msg, 0, 4);
        }
        else if ($len === 127) {
            $this->masks = substr ($msg, 10, 4);
            $data = substr ($msg, 14);
            $this->initFrame = substr ($msg, 0, 10);
        }
        else {
            $this->masks = substr ($msg, 2, 4);
            $data = substr ($msg, 6);
            $this->initFrame = substr ($msg, 0, 2);
        }
        for ($index = 0; $index < strlen ($data); $index++) {
            $decoded .= $data[$index] ^ $this->masks[$index % 4];
        }
        return $decoded;
    }
----------------

Should there be some regonizion when frame end and then attach rest of the 
message to second frame?

Original issue reported on code.google.com by [email protected] on 15 Nov 2012 at 9:35

主要语言
PHP
星标
0
派生
0
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

et-nik/phpwebsocket 的其他 Issue

查看 et-nik/phpwebsocket 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。