unnivm / jwebsocket

Automatically exported from code.google.com/p/jwebsocket
1 stars 0 forks source link

org.jwebsocket.kit.WebSocketHandshake insertSpaces method can insert leading and trailing spaces - Cause Md5 hash check to fail #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Run Websocket client against another WebSocket Server, like JBoss HornetQ

What is the expected output? What do you see instead?
Occasionally the connection fails in verifyServerResponse() with an error of 
"not a WebSocket Server".

What version of the product are you using? On what operating system?
0.1.0 on XP 64-bit

Please provide any additional information below.

The problem can be traced to leading or trailing spaces in the HTTP header.
These get stripped as there are no delimiters on a HTTP header field.  Changing 
the insertSpaces method to limit between the first and last character of the 
key seems to correct the issue.

 private String insertSpaces(String key, int spaces) {
        int maxSplit = key.length() - 1;
        for (int i = 0; i < spaces; i++) {
            int split = rand(1, maxSplit);
            String part1 = key.substring(0, split);
            String part2 = key.substring(split);
            key = part1 + " " + part2;
        }
        return key;
    }

Original issue reported on code.google.com by jlstro...@gmail.com on 9 Nov 2010 at 6:15

GoogleCodeExporter commented 9 years ago
This should have been done already in latest trunk.
Please refer to: http://code.google.com/p/jwebsocket/issues/detail?id=35.
But of course we will cross-check again in v0.11 QA.

Original comment by fivefeetfurther@gmail.com on 10 Nov 2010 at 11:07

GoogleCodeExporter commented 9 years ago

Original comment by fivefeetfurther@gmail.com on 10 Nov 2010 at 11:08