Module: kamailio
Branch: master
Commit: 8f6e826576e52270f21c22a7d94b3026cc22c172
URL:
https://github.com/kamailio/kamailio/commit/8f6e826576e52270f21c22a7d94b302…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-09-06T20:35:08+02:00
core: ensure index of preprocessor directive conditions is not negative
- avoid accessing the array at negative index for else processing
---
Modified: src/core/cfg.lex
---
Diff:
https://github.com/kamailio/kamailio/commit/8f6e826576e52270f21c22a7d94b302…
Patch:
https://github.com/kamailio/kamailio/commit/8f6e826576e52270f21c22a7d94b302…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index 00fd4b5e49..53f33431df 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -1942,14 +1942,24 @@ static void pp_ifdef()
static void pp_else()
{
+ if(pp_sptr==0) {
+ LM_WARN("invalid position for preprocessor directive 'else'"
+ " - at %s line %d\n", (finame)?finame:"cfg", line);
+ return;
+ }
pp_ifdef_stack[pp_sptr-1] ^= 1;
pp_update_state();
}
static void pp_endif()
{
- pp_sptr--;
pp_ifdef_level_update(-1);
+ if(pp_sptr==0) {
+ LM_WARN("invalid position for preprocessor directive 'else'"
+ " - at %s line %d\n", (finame)?finame:"cfg", line);
+ return;
+ }
+ pp_sptr--;
pp_update_state();
}