New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cfg parse error behaviour on a mismatch of #!ifdef/#!endif statements #2057
Comments
While looking at the code I discovered that the index of preprocessor conditions could become negative and even be used for a wrongly placed #!else - I pushed a fix for it: 8f6e826 -- this probably needs to be backported. Otherwise, it is fine for me to stop starting kamailio on a mismatch of ifdef/ifndef-endif pairs. But backporting to old stable branches might cause troubles, with kamailio not starting after upgrade, so I would keep it for 5.3 and the future. |
Thank you Daniel, the example from above works now. Unfortunately the opposite condition still not work:
|
What exactly do you mean by the opposite condition? For the example above I see it fails due to bad config file. |
The cfg is invalid, to reproduce it easier. My expectation would be that the config would load fine, as the "bar" condition is not defined at all. |
But maybe it is easier to just stop loading the cfg in this mismatch conditions. |
In that example, the config is invalid because it is empty, you have 3 ifdefs, then two endifs, so that ifdef bar is all together skipped to the end of the file. The error line is 19, which is the end of the file. This case is ok imo. |
Ah, I misread the line number. You are right. The backport of 8f6e826 is then only open, I think. |
You can backport, if you want. Otherwise I will do it before the next release in the 5.2 series. |
Done |
The #!ifdef/#endif statement parsing of the kamailio.cfg does not work correctly on a mismatch of #!ifdef/#!define statements. In some cases will just ignore the #!defines and parses the cfg file without the statements.
version: kamailio 5.3.0-pre0 (x86_64/linux) ed10d7
Test cfg to show the problem:
The "bar" condition is parsed, even if the #!define was not set. The WARN message is also not shown in this error case.
Probably the easist fix would be to stop kamailio startup on a mismatch of #!ifdef/#endif statements and output ERROR instead of the current WARN.
The text was updated successfully, but these errors were encountered: