Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r1300 committed - Firefox adds an unexpected piece to one of the headers, so we had to c...

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r1300 committed - Firefox adds an unexpected piece to one of the headers, so we had to c...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r1300 committed - Firefox adds an unexpected piece to one of the headers, so we had to c...
  • Date: Mon, 06 Apr 2015 20:45:17 +0000

Revision: 1300
Author:

Date: Mon Apr 6 20:45:03 2015 UTC
Log: Firefox adds an unexpected piece to one of the headers, so we had to change the
header parsing and validation slightly.


https://code.google.com/p/ndt/source/detail?r=1300

Modified:
/branches/websockets/src/websocket.c
/branches/websockets/src/websocket_unit_tests.c

=======================================
--- /branches/websockets/src/websocket.c Mon Mar 23 22:59:30 2015 UTC
+++ /branches/websockets/src/websocket.c Mon Apr 6 20:45:03 2015 UTC
@@ -365,7 +365,8 @@
const static unsigned int MAX_HEADER_LENGTH = 8192;
// String constants used when making a websocket connection.
const static char UPGRADE_HEADER[] = "Upgrade: websocket";
- const static char CONNECTION_HEADER[] = "Connection: Upgrade";
+ const static char CONNECTION_HEADER[] = "Connection: ";
+ const static char CONNECTION_HEADER_VALUE[] = " Upgrade";
const static char VERSION_HEADER[] = "Sec-WebSocket-Version: 13";
const static char WS_KEY[] = "Sec-WebSocket-Key: ";

@@ -389,8 +390,10 @@
for (i = 0; i < MAX_HEADER_COUNT; i++) {
if (strcmp(line, UPGRADE_HEADER) == 0) {
validated_upgrade = 1;
- } else if (strcmp(line, CONNECTION_HEADER) == 0) {
- validated_connection = 1;
+ } else if (strncmp(line, CONNECTION_HEADER, strlen(CONNECTION_HEADER)) == 0) {
+ if (strstr(line, CONNECTION_HEADER_VALUE) != NULL) {
+ validated_connection = 1;
+ }
} else if (strcmp(line, VERSION_HEADER) == 0) {
validated_version = 1;
} else if (strncmp(line, WS_PROTOCOL, strlen(WS_PROTOCOL)) == 0) {
=======================================
--- /branches/websockets/src/websocket_unit_tests.c Mon Mar 23 22:59:30 2015 UTC
+++ /branches/websockets/src/websocket_unit_tests.c Mon Apr 6 20:45:03 2015 UTC
@@ -326,6 +326,34 @@
"\r\n";
check_websocket_handshake(header, response);
}
+
+void test_firefox_websocket_handshake() {
+ const char* header =
+ "GET /ndt_after_user_privacy_agreement HTTP/1.1\r\n"
+ "Host: ndt.iupui.mlab2.nuq0t.measurement-lab.org:7000\r\n"
+ "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101\r\n"
+ "Firefox/35.0 Iceweasel/35.0.1\r\n"
+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
+ "Accept-Language: en,es;q=0.7,en-us;q=0.3\r\n"
+ "Accept-Encoding: gzip, deflate\r\n"
+ "Sec-WebSocket-Version: 13\r\n"
+ "Origin: null\r\n"
+ "Sec-WebSocket-Protocol: ndt\r\n"
+ "Sec-WebSocket-Key: FXsRm8SyAc2WCzXCn248UQ==\r\n"
+ "Connection: keep-alive, Upgrade\r\n"
+ "Pragma: no-cache\r\n"
+ "Cache-Control: no-cache\r\n"
+ "Upgrade: websocket\r\n"
+ "\r\n";
+ const char* response =
+ "HTTP/1.1 101 Switching Protocols\r\n"
+ "Upgrade: websocket\r\n"
+ "Connection: Upgrade\r\n"
+ "Sec-WebSocket-Protocol: ndt\r\n"
+ "Sec-WebSocket-Accept: pe2T6IrtSYYz+YUvcOLw1n/ioLc=\r\n"
+ "\r\n";
+ check_websocket_handshake(header, response);
+}

void test_websocket_sha() {
const char key[] = "dGhlIHNhbXBsZSBub25jZQ==";
@@ -382,5 +410,7 @@
RUN_TEST(test_rfc_example_fragmented_with_ping) |
RUN_TEST(test_rfc_example_masked_hello) |
RUN_TEST(test_send_digest_base64) |
- RUN_TEST(test_websocket_handshake) | RUN_TEST(test_websocket_sha);
+ RUN_TEST(test_websocket_handshake) |
+ RUN_TEST(test_firefox_websocket_handshake) |
+ RUN_TEST(test_websocket_sha);
}


  • [ndt-dev] [ndt] r1300 committed - Firefox adds an unexpected piece to one of the headers, so we had to c..., ndt, 04/06/2015

Archive powered by MHonArc 2.6.16.

Top of Page