mirror of
https://github.com/telemt/telemt.git
synced 2026-07-07 20:40:15 +03:00
Harden masking fallback and frame readers after flow sync
Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
This commit is contained in:
@@ -1940,6 +1940,13 @@ impl ProxyConfig {
|
||||
));
|
||||
}
|
||||
|
||||
if config.server.listen_backlog == 0 || config.server.listen_backlog > i32::MAX as u32 {
|
||||
return Err(ProxyError::Config(format!(
|
||||
"server.listen_backlog must be within [1, {}]",
|
||||
i32::MAX
|
||||
)));
|
||||
}
|
||||
|
||||
config
|
||||
.server
|
||||
.client_mss_value()
|
||||
|
||||
@@ -95,6 +95,44 @@ max_client_frame = 16777217
|
||||
remove_temp_config(&path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_rejects_listen_backlog_above_i32_upper_bound() {
|
||||
let path = write_temp_config(
|
||||
r#"
|
||||
[server]
|
||||
listen_backlog = 2147483648
|
||||
"#,
|
||||
);
|
||||
|
||||
let err = ProxyConfig::load(&path).expect_err("listen_backlog above socket cap must fail");
|
||||
let msg = err.to_string();
|
||||
assert!(
|
||||
msg.contains("server.listen_backlog must be within [1, 2147483647]"),
|
||||
"error must explain listen_backlog hard cap, got: {msg}"
|
||||
);
|
||||
|
||||
remove_temp_config(&path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_rejects_zero_listen_backlog() {
|
||||
let path = write_temp_config(
|
||||
r#"
|
||||
[server]
|
||||
listen_backlog = 0
|
||||
"#,
|
||||
);
|
||||
|
||||
let err = ProxyConfig::load(&path).expect_err("zero listen_backlog must fail");
|
||||
let msg = err.to_string();
|
||||
assert!(
|
||||
msg.contains("server.listen_backlog must be within [1, 2147483647]"),
|
||||
"error must explain listen_backlog lower bound, got: {msg}"
|
||||
);
|
||||
|
||||
remove_temp_config(&path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_accepts_memory_limits_at_hard_upper_bounds() {
|
||||
let path = write_temp_config(
|
||||
|
||||
Reference in New Issue
Block a user