Reject oversized service strings and cover scalar bounds

This commit is contained in:
evgeny committed 2026-10-26 09:08:23 +01:00
1 parent f1388d8822
commit db2c88f7d9
2 files changed
+12 -18

No files matched your search

+6 -17
View File
@@ -790,14 +790,10 @@ static int parse_size_with_suffix(const char *value, uint64_t *out_bytes) {
static int parse_chatserver(const char *key, const char *value, struct global_config *global, const char *filename, int line_num) {
if (strcmp(key, "join_password") == 0) {
strncpy(global->chatserver_join_password, value, sizeof(global->chatserver_join_password) - 1);
global->chatserver_join_password[sizeof(global->chatserver_join_password) - 1] = '\0';
return 0;
return assign_string(global->chatserver_join_password, sizeof(global->chatserver_join_password), value);
}
if (strcmp(key, "allowed_groups") == 0) {
strncpy(global->chatserver_allowed_groups, value, sizeof(global->chatserver_allowed_groups) - 1);
global->chatserver_allowed_groups[sizeof(global->chatserver_allowed_groups) - 1] = '\0';
return 0;
return assign_string(global->chatserver_allowed_groups, sizeof(global->chatserver_allowed_groups), value);
}
if (strcmp(key, "storage_total_size") == 0) {
uint64_t sz;
@@ -818,19 +814,13 @@ static int parse_chatserver(const char *key, const char *value, struct global_co
return 0;
}
if (strcmp(key, "headless_control_bind") == 0) {
strncpy(global->headless_control_bind, value, sizeof(global->headless_control_bind) - 1);
global->headless_control_bind[sizeof(global->headless_control_bind) - 1] = '\0';
return 0;
return assign_string(global->headless_control_bind, sizeof(global->headless_control_bind), value);
}
if (strcmp(key, "call_audio_bind") == 0) {
strncpy(global->call_audio_bind, value, sizeof(global->call_audio_bind) - 1);
global->call_audio_bind[sizeof(global->call_audio_bind) - 1] = '\0';
return 0;
return assign_string(global->call_audio_bind, sizeof(global->call_audio_bind), value);
}
if (strcmp(key, "radio_audio_bind") == 0) {
strncpy(global->radio_audio_bind, value, sizeof(global->radio_audio_bind) - 1);
global->radio_audio_bind[sizeof(global->radio_audio_bind) - 1] = '\0';
return 0;
return assign_string(global->radio_audio_bind, sizeof(global->radio_audio_bind), value);
}
return -1;
}
@@ -1160,8 +1150,7 @@ struct utun_config* parse_config_from_buf(const char *buf, size_t len, const cha
} else if (strcmp(key, "netif") == 0) {
cfg->global.tcp_proxy_server_netif_index = get_netif_index(value);
} else if (strcmp(key, "bind_ip") == 0) {
strncpy(cfg->global.tcp_proxy_server_bind_ip, value, sizeof(cfg->global.tcp_proxy_server_bind_ip) - 1);
cfg->global.tcp_proxy_server_bind_ip[sizeof(cfg->global.tcp_proxy_server_bind_ip) - 1] = '\0';
option_result = assign_string(cfg->global.tcp_proxy_server_bind_ip, sizeof(cfg->global.tcp_proxy_server_bind_ip), value);
} else if (strcmp(key, "connect_timeout") == 0) {
option_result = parse_integer(value, 0, INT_MAX / 10, &cfg->global.tcp_proxy_server_connect_timeout_ms);
} else {