Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解析packet出错 #53

Open
ClarkMiaguo opened this issue Apr 25, 2021 · 1 comment
Open

解析packet出错 #53

ClarkMiaguo opened this issue Apr 25, 2021 · 1 comment

Comments

@ClarkMiaguo
Copy link

在clusterClient模式下, 手贱去telnet了下端口,结果程序crash了.

看了下, lib/server.js

if (!header) {
        header = socket.read(24);
        if (!header) {
          return;
        }
      }
      if (!bodyLength) {
        bodyLength = header.readInt32BE(16) + header.readInt32BE(20);
      }

header = socket.read(24)在connection断开后,header是有值的, 根据buffer内的实际长度返回,随后是header.readInt32BE(16) 就可能出现exception, 如RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 11. Received 16

是不是考虑也判断下header的长度 === 24, 至少这样不至于程序崩溃

@ClarkMiaguo
Copy link
Author

@gxcsoccer @fengmk2 @atian25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant