Module: kamailio
Branch: master
Commit: 5430f7e1ea98f268b0ba7aef88a7e471e6940c4d
URL:
https://github.com/kamailio/kamailio/commit/5430f7e1ea98f268b0ba7aef88a7e47…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-11-24T12:53:13+01:00
core: added core parameter mem_add_size
- default value 0
- to be used to add extra space to allocated chunks for safety purposes
when external libraries expose buffer overflows
---
Modified: src/core/cfg.lex
Modified: src/core/cfg.y
Modified: src/core/globals.h
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5430f7e1ea98f268b0ba7aef88a7e47…
Patch:
https://github.com/kamailio/kamailio/commit/5430f7e1ea98f268b0ba7aef88a7e47…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index e1c9215cd7e..be4467efa88 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -385,6 +385,7 @@ MEMLOG "memlog"|"mem_log"
MEMDBG "memdbg"|"mem_dbg"
MEMSUM "mem_summary"
MEMSAFETY "mem_safety"
+MEMADDSIZE "mem_add_size"
MEMJOIN "mem_join"
MEMSTATUSMODE "mem_status_mode"
CORELOG "corelog"|"core_log"
@@ -874,6 +875,7 @@ IMPORTFILE "import_file"
<INITIAL>{MEMDBG} { count(); yylval.strval=yytext; return MEMDBG; }
<INITIAL>{MEMSUM} { count(); yylval.strval=yytext; return MEMSUM; }
<INITIAL>{MEMSAFETY} { count(); yylval.strval=yytext; return MEMSAFETY; }
+<INITIAL>{MEMADDSIZE} { count(); yylval.strval=yytext; return MEMADDSIZE; }
<INITIAL>{MEMJOIN} { count(); yylval.strval=yytext; return MEMJOIN; }
<INITIAL>{MEMSTATUSMODE} { count(); yylval.strval=yytext; return MEMSTATUSMODE; }
<INITIAL>{SIP_PARSER_LOG_ONELINE} { count(); yylval.strval=yytext; return
SIP_PARSER_LOG_ONELINE; }
diff --git a/src/core/cfg.y b/src/core/cfg.y
index b9e293aa923..545ca7fdc66 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -401,6 +401,7 @@ extern char *default_routename;
%token MEMDBG
%token MEMSUM
%token MEMSAFETY
+%token MEMADDSIZE
%token MEMJOIN
%token MEMSTATUSMODE
%token SIP_PARSER_LOG_ONELINE
@@ -1072,6 +1073,8 @@ assign_stm:
| MEMSUM EQUAL error { yyerror("int value expected"); }
| MEMSAFETY EQUAL intno { default_core_cfg.mem_safety=$3; }
| MEMSAFETY EQUAL error { yyerror("int value expected"); }
+ | MEMADDSIZE EQUAL intno { ksr_mem_add_size=$3; }
+ | MEMADDSIZE EQUAL error { yyerror("int value expected"); }
| MEMJOIN EQUAL intno { default_core_cfg.mem_join=$3; }
| MEMJOIN EQUAL error { yyerror("int value expected"); }
| MEMSTATUSMODE EQUAL intno { default_core_cfg.mem_status_mode=$3; }
diff --git a/src/core/globals.h b/src/core/globals.h
index f097d120c96..f8b77edb328 100644
--- a/src/core/globals.h
+++ b/src/core/globals.h
@@ -165,6 +165,8 @@ extern int reply_to_via;
extern int _ksr_is_main;
extern int fixup_complete;
+extern int ksr_mem_add_size;
+
/* debugging level for dumping memory status */
extern int memlog;
/* debugging level for malloc debugging messages */
diff --git a/src/main.c b/src/main.c
index 2231fa2c945..db694381421 100644
--- a/src/main.c
+++ b/src/main.c
@@ -547,6 +547,7 @@ static int *_sr_instance_started = NULL;
int ksr_cfg_print_mode = 0;
int ksr_atexit_mode = 0;
+int ksr_mem_add_size = 0;
int ksr_wait_worker1_mode = 0;
int ksr_wait_worker1_time = 4000000;