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

Fixes protocol handling. Smallest frame size is 6 for ping frames. #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/kws.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da
return kws_close(kws, WS_NONE);
}

if ((kws->datalen = kws_raw_read(kws, kws->buffer, 9, kws->block)) < 0) {
if ((kws->datalen = kws_raw_read(kws, kws->buffer, 6, kws->block)) < 0) {
ks_log(KS_LOG_ERROR, "Read frame error because kws_raw_read returned %ld\n", kws->datalen);
if (kws->datalen == -2) {
return -2;
Expand All @@ -1104,7 +1104,7 @@ KS_DECLARE(ks_ssize_t) kws_read_frame(kws_t *kws, kws_opcode_t *oc, uint8_t **da
}

if (kws->datalen < need) {
ssize_t bytes = kws_raw_read(kws, kws->buffer + kws->datalen, 9 - kws->datalen, WS_BLOCK);
ssize_t bytes = kws_raw_read(kws, kws->buffer + kws->datalen, 6 - kws->datalen, WS_BLOCK);

if (bytes < 0 || (kws->datalen += bytes) < need) {
/* too small - protocol err */
Expand Down