Skip to content

bug in BASE64Encode in websocket_threaded_example.c #33

@timredfern

Description

@timredfern

I found an issue in the encoding function in this example. As it stands, the Sec-WebSocket-Key field is returned incorrectly and thus clients that check this cannot connect.

It's only one line to change so I don't know if it's worth getting permission to create a branch or fork the project.

This is the patch:

index 50919190..fec8e631 100644
--- a/src/examples/websocket_threaded_example.c
+++ b/src/examples/websocket_threaded_example.c
@@ -387,7 +387,7 @@ BASE64Encode (const void *in, size_t len, char **output)
     opt[ret++] = cvt[(int) c];
     if (i < len)
     {
-      c = (char) (c | ((data[i] << 2) & 0x3F));
+      c = (char) ((data[i] << 2) & 0x3F);
       if (++i < len)
       {
         c = (char) (c | ((data[i] >> 6) & 0x03));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions