View Issue Details

IDProjectCategoryView StatusLast Update
0000272AlmaLinux-9keepalivedpublic2022-06-27 10:19
ReporterPhilRandal Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
OSAlmaLinuxOS Version9.0 
Summary0000272: keepalived 2.2.4 doesn't correctly handle variable substitution in conditional lines
Descriptionman keepalived.conf clearly states

"
           $IF_MAIN=@main
           $IF_MAIN priority 240

           will produce:
               priority 240
               if the config_id is main and nothing if the config_id is not main,
               although why anyone would want to use this rather than simply the
               following is not known (but still possible):
                   @main priority 240

"

Yet this does not work correctly under all circumstances.
Steps To Reproduceset the following in keepalived.conf

$PRI=@my-server-id

$PRI priority 240 on expansion

will produce garbled output

Unknown keyword 'priorixxxx' where xxxx is trailing part of host name.

Reproducible on both AlmaLinux 8.6 andd 9.0
Additional InformationThe reason is that after the variable value substitution, the line-length is not recalculated.

Fix is to apply the following patch

I've recalculated the buffer length at the head of the loop for obvious correctness and
resilience in the case of future code changes

--- a/lib/parser.c 2022-06-27 08:58:01.163365991 +0100
+++ b/lib/parser.c 2022-06-27 09:05:08.456532867 +0100
@@ -2735,7 +2735,8 @@

                do {
                        recheck = false;
- if (buf[0] == '@') {
+ len = strlen(buf);
+ if (buf[0] == '@') {
                                /* If the line starts '@', check the following word matches the system id.
                                   @^ reverses the sense of the match */
                                if (buf[1] == '^') {

TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2022-06-27 10:19 PhilRandal New Issue