etc/kamailio.cfg: added checks for msg and r-uri size

- message up to 16384 and r-uri up to 512 bytes
- discard quickly the messages that are too large for a typical UA,
  avoid extra processing to discover later UA is not valid (e.g., by
  auth)
This commit is contained in:
Daniel-Constantin Mierla 2026-03-31 17:42:11 +02:00
parent 9e1d97dd3f
commit 3609b9d700

View file

@ -168,6 +168,10 @@ import_file "kamailio-local.cfg"
#!define FLB_NATB 6
#!define FLB_NATSIPPING 7
# - values
#!trydef MSG_MAX_SIZE 16384
#!trydef RURI_MAX_SIZE 512
####### Global Parameters #########
/* LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR, ... */
@ -670,6 +674,14 @@ route[REQINIT] {
# sl_send_reply("200", "OK");
exit;
}
if($msg(len) > MSG_MAX_SIZE) {
sl_send_reply("403", "Message too large");
exit;
}
if($(ru{s.len}) > RURI_MAX_SIZE) {
sl_send_reply("403", "R-URI too large");
exit;
}
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483", "Too Many Hops");
@ -1065,6 +1077,10 @@ reply_route {
xlog("Malformed SIP response from $si:$sp\n");
drop;
}
if($msg(len) > MSG_MAX_SIZE) {
drop;
}
return;
}