Skip to content

Commit

Permalink
http: setEncoding override for incoming packets
Browse files Browse the repository at this point in the history
added override to socket.setEncoding to not allow encoding changes for
incoming HTTP requests
added tests to ensure method throws JavaScript error
because an HTTP buffer must be in US-ASCII, this function should not
be allowed and should throw an Error
currently, the process encounters a fatal v8 error and crashes

error report detailed in
[issue nodejs#18118](nodejs#18118)

Fixes: nodejs#18118
Ref: nodejs#18178
  • Loading branch information
iSkore committed Apr 3, 2018
1 parent a820f41 commit a7e2aab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/_http_server.js
Expand Up @@ -383,6 +383,7 @@ function connectionListenerInternal(server, socket) {

// Override on to unconsume on `data`, `readable` listeners
socket.on = socketOnWrap;
socket.setEncoding = socketSetEncoding;

// We only consume the socket if it has never been consumed before.
if (socket._handle) {
Expand Down Expand Up @@ -683,6 +684,10 @@ function onSocketPause() {
}
}

function socketSetEncoding() {
throw new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', 'setEncoding');
}

function unconsume(parser, socket) {
if (socket._handle) {
if (parser._consumed)
Expand Down

0 comments on commit a7e2aab

Please sign in to comment.