Skip to content

kws_read_frame when receive a short ping frame #180

@shanghaimoon888

Description

@shanghaimoon888

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions