termio/exec: limit max apc string length

This commit is contained in:
Mitchell Hashimoto
2023-08-18 13:56:33 -07:00
parent 6e061fb344
commit bddf8a8cb3

View File

@ -1107,6 +1107,14 @@ const StreamHandler = struct {
}
try self.apc_data.append(self.alloc, byte);
// Prevent DoS attack.
const limit = 100 * 1024 * 1024; // 100MB
if (self.apc_data.items.len > limit) {
log.warn("APC command too large, ignoring", .{});
self.apc_state = .ignore;
self.apc_data.clearAndFree(self.alloc);
}
}
pub fn apcEnd(self: *StreamHandler) !void {