Module: kamailio
Branch: master
Commit: 9410ce3848c1ab7fa8b7ded47d090342fd4cf1c0
URL:
https://github.com/kamailio/kamailio/commit/9410ce3848c1ab7fa8b7ded47d09034…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-30T10:05:29+01:00
core: cfg.y - check limit for shm size
---
Modified: src/core/cfg.y
---
Diff:
https://github.com/kamailio/kamailio/commit/9410ce3848c1ab7fa8b7ded47d09034…
Patch:
https://github.com/kamailio/kamailio/commit/9410ce3848c1ab7fa8b7ded47d09034…
---
diff --git a/src/core/cfg.y b/src/core/cfg.y
index 545ca7fdc66..c357faa927d 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -1865,11 +1865,18 @@ assign_stm:
| OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
| SHM_MEM_SZ EQUAL NUMBER {
- if (shm_initialized())
+ if (shm_initialized()) {
yyerror("shm/shm_mem_size must be before any modparam or the"
" route blocks");
- else if (shm_mem_size == 0 || shm_mem_size == SHM_MEM_POOL_SIZE)
+ } else if (shm_mem_size == 0 || shm_mem_size == SHM_MEM_POOL_SIZE) {
+ /* safety check for upper limit of 16TB */
+ if($3 <= 0 || $3 > 16L * 1024 * 1024) {
+ LM_ERR("out of limits shmem size number: %ld\n", (long int)$3);
+ yyerror("invalid config option");
+ YYABORT;
+ }
shm_mem_size=$3 * 1024 * 1024;
+ }
}
| SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
| SHM_FORCE_ALLOC EQUAL NUMBER {