Changeset 87282 in webkit
- Timestamp:
- May 25, 2011 2:52:36 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87280 r87282 1 2011-05-25 Yuta Kitamura <yutak@chromium.org> 2 3 Reviewed by Kent Tamura. 4 5 WebSocket: Use fail() when WebSocketChannel has failed 6 https://bugs.webkit.org/show_bug.cgi?id=61353 7 8 * http/tests/websocket/tests/frame-length-overflow-expected.txt: 9 Added a new console message. 10 1 11 2011-05-24 Pavel Podivilov <podivilov@chromium.org> 2 12 -
trunk/LayoutTests/http/tests/websocket/tests/frame-length-overflow-expected.txt
r65135 r87282 1 CONSOLE MESSAGE: line 0: WebSocket frame length too large 1 2 Make sure WebSocket does not crash and report error when it sees length overflow 2 3 -
trunk/Source/WebCore/ChangeLog
r87281 r87282 1 2011-05-25 Yuta Kitamura <yutak@chromium.org> 2 3 Reviewed by Kent Tamura. 4 5 WebSocket: Use fail() when WebSocketChannel has failed 6 https://bugs.webkit.org/show_bug.cgi?id=61353 7 8 An existing error message has been modified, but it is impossible 9 to test this message in LayoutTests because it is only shown when 10 memory allocation has failed, which is hard to reproduce reliably. 11 12 One new message has been added. It is covered by an existing test 13 http/tests/websocket/tests/frame-length-overflow.html. 14 15 There is no other change in behavior. No new tests are added. 16 17 * websockets/WebSocketChannel.cpp: 18 (WebCore::WebSocketChannel::fail): 19 Do not close if we know the socket stream is already closed. This does not 20 change the behavior, because SocketStreamBase does nothing if it is already 21 closed. 22 (WebCore::WebSocketChannel::didOpen): 23 (WebCore::WebSocketChannel::didReceiveData): 24 We need to set m_shouldDiscardReceivedData to true before calling fail(), 25 so I moved the error message from appendToBuffer() to here. 26 The error message was rephrased in order to improve readability. 27 (WebCore::WebSocketChannel::appendToBuffer): 28 Unnested the code. 29 (WebCore::WebSocketChannel::processBuffer): 30 1 31 2011-05-16 Alexander Pavlov <apavlov@chromium.org> 2 32 -
trunk/Source/WebCore/websockets/WebSocketChannel.cpp
r87139 r87282 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 128 128 if (m_context) 129 129 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, reason, 0, m_handshake.clientOrigin(), 0); 130 if (m_handle )130 if (m_handle && !m_closed) 131 131 m_handle->close(); // Will call didClose(). 132 132 } … … 165 165 InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_context, m_identifier, m_handshake.clientHandshakeRequest()); 166 166 CString handshakeMessage = m_handshake.clientHandshakeMessage(); 167 if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) { 168 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin(), 0); 169 handle->close(); 170 } 167 if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) 168 fail("Failed to send WebSocket handshake."); 171 169 } 172 170 … … 209 207 if (!appendToBuffer(data, len)) { 210 208 m_shouldDiscardReceivedData = true; 211 handle->close();209 fail("Ran out of memory while receiving WebSocket data."); 212 210 return; 213 211 } … … 255 253 } 256 254 char* newBuffer = 0; 257 if (tryFastMalloc(newBufferSize).getValue(newBuffer)) { 258 if (m_buffer) 259 memcpy(newBuffer, m_buffer, m_bufferSize); 260 memcpy(newBuffer + m_bufferSize, data, len); 261 fastFree(m_buffer); 262 m_buffer = newBuffer; 263 m_bufferSize = newBufferSize; 264 return true; 265 } 266 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "WebSocket frame (at " + String::number(static_cast<unsigned long>(newBufferSize)) + " bytes) is too long.", 0, m_handshake.clientOrigin(), 0); 267 return false; 255 if (!tryFastMalloc(newBufferSize).getValue(newBuffer)) 256 return false; 257 258 if (m_buffer) 259 memcpy(newBuffer, m_buffer, m_bufferSize); 260 memcpy(newBuffer + m_bufferSize, data, len); 261 fastFree(m_buffer); 262 m_buffer = newBuffer; 263 m_bufferSize = newBufferSize; 264 return true; 268 265 } 269 266 … … 362 359 m_shouldDiscardReceivedData = true; 363 360 m_client->didReceiveMessageError(); 364 if (!m_client) 365 return false; 366 if (!m_closed) 367 m_handle->close(); 361 fail("WebSocket frame length too large"); 368 362 return false; 369 363 }
Note: See TracChangeset
for help on using the changeset viewer.