Bug 742614: Allocation of string is not checked in WebSockets text frame parsing. r=bsmith

This commit is contained in:
Jason Duell 2012-05-11 02:05:00 -07:00
parent f8c10a1c5b
commit f7e8936e78

View File

@ -1050,7 +1050,10 @@ WebSocketChannel::ProcessInput(PRUint8 *buffer, PRUint32 count)
} else if (opcode == kText) {
LOG(("WebSocketChannel:: text frame received\n"));
if (mListener) {
nsCString utf8Data((const char *)payload, payloadLength);
nsCString utf8Data;
if (!utf8Data.Assign((const char *)payload, payloadLength,
mozilla::fallible_t()))
return NS_ERROR_OUT_OF_MEMORY;
// Section 8.1 says to fail connection if invalid utf-8 in text message
if (!IsUTF8(utf8Data, false)) {