Prevented "write after end" SVR.JS crashes (even more)

This commit is contained in:
Dorian Niemiec 2024-02-21 01:13:03 +01:00
parent f0977c9319
commit 6e882fdbc8

View file

@ -178,7 +178,10 @@ function createFastCGIHandler(options) {
//STDERR will be lost anyway...
}
} else if (processedPacket.type == END_REQUEST && processedPacket.content.length > 5) {
if (typeof socket !== "undefined") socket.removeListener("data", fastCGISocketHandler);
if (typeof socket !== "undefined") {
socket.removeListener("data", fastCGISocketHandler);
processFastCGIPacket = function() {};
}
var appStatus = processedPacket.content.readUInt32BE(0);
var protocolStatus = processedPacket.content.readUInt8(4);
if (protocolStatus != REQUEST_COMPLETE) {
@ -283,6 +286,8 @@ function createFastCGIHandler(options) {
eventEmitter.emit("error", err);
}).on("data", fastCGISocketHandler);
eventEmitter.socket = socket;
return eventEmitter;
}
@ -465,7 +470,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
}
});
handler.on("connect", function () {
function handlerConnection() {
handler.init();
handler.stdout.on("data", dataHandler);
handler.stderr.on("data", function (data) {
@ -491,7 +496,9 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
res.end();
}
});
});
}
if(typeof handler.socket.connecting == "undefined" || handler.socket.connecting) handler.on("connect", handlerConnection);
else if(!handler.socket.destroyed) handlerConnection();
}
function executeFastCGIWithEnv(a, b, req, res, pubip, port, software, dh, user, cPath) {