Skip to content

Commit a7e2aab

Browse files
committed
http: setEncoding override for incoming packets
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
1 parent a820f41 commit a7e2aab

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/_http_server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ function connectionListenerInternal(server, socket) {
383383

384384
// Override on to unconsume on `data`, `readable` listeners
385385
socket.on = socketOnWrap;
386+
socket.setEncoding = socketSetEncoding;
386387

387388
// We only consume the socket if it has never been consumed before.
388389
if (socket._handle) {
@@ -683,6 +684,10 @@ function onSocketPause() {
683684
}
684685
}
685686

687+
function socketSetEncoding() {
688+
throw new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', 'setEncoding');
689+
}
690+
686691
function unconsume(parser, socket) {
687692
if (socket._handle) {
688693
if (parser._consumed)

0 commit comments

Comments
 (0)