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

kws_read_frame when receive a short ping frame #180

Open
shanghaimoon888 opened this issue Nov 29, 2023 · 1 comment
Open

kws_read_frame when receive a short ping frame #180

shanghaimoon888 opened this issue Nov 29, 2023 · 1 comment

Comments

@shanghaimoon888
Copy link

Where the function kws_read_frame() read a ping frame which the frame length is 6(2 header and 4 payload) and followed with a text frame. Then the code below will make the kws->datalen to be 9:
if ((kws->datalen = kws_string_read(kws, kws->buffer, 9 + 1, kws->block)) < 0)
This will trigger the error in below code because the need will be -3:
need = (kws->plen - (kws->datalen - need));
if (need < 0) {
/* invalid read - protocol err .. */
ks_log(KS_LOG_ERROR, "Read frame error because need = %ld\n", need);
*oc = WSOC_CLOSE;
return kws_close(kws, WS_NONE);
}
I have modify the code to:
if ((kws->datalen = kws_string_read(kws, kws->buffer, 6 + 1, kws->block)) < 0)
and it seems worked. But if the ping frame length is less than 6, the error is still exist. What about a perfect solution?

@chucongqing
Copy link
Contributor

#181

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

2 participants