Validate that the close reason is proper utf-8. Autobahn 7.5.1

This commit is contained in:
Benjamin Sergeant
2019-09-03 14:35:40 -07:00
parent 51799353a6
commit 1be8d9d46f
2 changed files with 11 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include "IXWebSocketHttpHeaders.h"
#include "IXUrlParser.h"
#include "IXSocketFactory.h"
#include "IXUtf8Validator.h"
#include <string.h>
#include <stdlib.h>
@ -676,6 +677,13 @@ namespace ix
reason.assign(_rxbuf.begin()+ws.header_size + 2,
_rxbuf.begin()+ws.header_size + (size_t) ws.N);
}
// Validate that the reason is proper utf-8. Autobahn 7.5.1
if (!validateUtf8(reason))
{
code = WebSocketCloseConstants::kInvalidFramePayloadData;
reason = WebSocketCloseConstants::kInvalidFramePayloadDataMessage;
}
}
else
{