Module: kamailio Branch: 5.1 Commit: 26da74e4f8af192d876ac1d78eee9319f378c154 URL: https://github.com/kamailio/kamailio/commit/26da74e4f8af192d876ac1d78eee9319...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Henning Westerholt hw@skalatan.de Date: 2019-09-10T09:52:15+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/26da74e4f8af192d876ac1d78eee9319... Patch: https://github.com/kamailio/kamailio/commit/26da74e4f8af192d876ac1d78eee9319...
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex index cd6808d063..c470232067 100644 --- a/src/core/cfg.lex +++ b/src/core/cfg.lex @@ -1896,14 +1896,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(); }