Module: kamailio
Branch: 5.2
Commit: 71efcfbb059e72cb05572ef7d3f58ac2e7dba397
URL:
https://github.com/kamailio/kamailio/commit/71efcfbb059e72cb05572ef7d3f58ac…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2019-09-10T09:52:11+02:00
core: ensure index of preprocessor directive conditions is not negative
- avoid accessing the array at negative index for else processing
(cherry picked from commit 8f6e826576e52270f21c22a7d94b3026cc22c172)
---
Modified: src/core/cfg.lex
---
Diff:
https://github.com/kamailio/kamailio/commit/71efcfbb059e72cb05572ef7d3f58ac…
Patch:
https://github.com/kamailio/kamailio/commit/71efcfbb059e72cb05572ef7d3f58ac…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index 6a0d23d76f..6aa890f155 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -1922,14 +1922,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();
}