Skip to content
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

[bug]: app_if.c : nested EndIf incorrectly exits parent If #341

Closed
1 task done
asolovjov opened this issue Sep 20, 2023 · 0 comments · Fixed by #512
Closed
1 task done

[bug]: app_if.c : nested EndIf incorrectly exits parent If #341

asolovjov opened this issue Sep 20, 2023 · 0 comments · Fixed by #512
Labels
bug support-level-extended Functionality with extended support level

Comments

@asolovjov
Copy link

Severity

Trivial

Versions

18

Components/Modules

app_if.c

Operating Environment

It doesn't matter.
Asterisk 18.19.0 built by builder @ builder.lo on a x86_64 running Linux on 2023-09-20 09:17:45

Frequency of Occurrence

None

Issue Description

If nested if block condition is true then EndIf exits the parent if block. (BTW, If condition is false, it works correctly. ExitIf also works correctly.)
Example simple dialplan:

exten => _iftest,1,Noop
    same => n,If(1)
        same => n,Noop(inside main if)
        same => n,If(0)
            same => n,Noop()
        same => n,Endif
        same => n,Noop(after nested false if)
        same => n,If(1)
            same => n,Noop(inside true nested if)
        same => n,Endif
        same => n,Noop(after nested true if)
    same => n,Endif
    same => n,Noop(after main if)
    same => n,Hangup

> dialplan show iftest@test                                                                                                                                                                                                
[ Context 'test' created by 'pbx_config' ]
  '_iftest' =>      1. Noop()                                     [extensions_custom.conf:487]
                    2. If(1)                                      [extensions_custom.conf:488]
                    3. Noop(inside main if)                       [extensions_custom.conf:489]
                    4. If(0)                                      [extensions_custom.conf:490]
                    5. Noop()                                     [extensions_custom.conf:491]
                    6. Endif()                                    [extensions_custom.conf:492]
                    7. Noop(after nested false if)                [extensions_custom.conf:493]
                    8. If(1)                                      [extensions_custom.conf:494]
                    9. Noop(inside true nested if)                [extensions_custom.conf:495]
                    10. Endif()                                   [extensions_custom.conf:496]
                    11. Noop(after nested true if)                [extensions_custom.conf:497]
                    12. Endif()                                   [extensions_custom.conf:498]
                    13. Noop(after main if)                       [extensions_custom.conf:499]
                    14. Hangup()                                  [extensions_custom.conf:500]

We should see "inside true nested if" and then "after nested true if". Instead we jump to priority 12:

    -- Executing [iftest@test:1] NoOp("SIP/y1103-00000015", "") in new stack
    -- Executing [iftest@test:2] If("SIP/y1103-00000015", "1") in new stack
    -- Executing [iftest@test:3] NoOp("SIP/y1103-00000015", "inside main if") in new stack
    -- Executing [iftest@test:4] If("SIP/y1103-00000015", "0") in new stack
    -- Exiting conditional, jumping to priority 6
    -- Executing [iftest@test:7] NoOp("SIP/y1103-00000015", "after nested false if") in new stack
    -- Executing [iftest@test:8] If("SIP/y1103-00000015", "1") in new stack
    -- Executing [iftest@test:9] NoOp("SIP/y1103-00000015", "inside true nested if") in new stack
    -- Executing [iftest@test:10] EndIf("SIP/y1103-00000015", "") in new stack
    -- Exiting conditional, jumping to priority 12
    -- Executing [iftest@test:13] NoOp("SIP/y1103-00000015", "after main if") in new stack
    -- Executing [iftest@test:14] Hangup("SIP/y1103-00000015", "") in new stack

Relevant log output

No response

Asterisk Issue Guidelines

  • Yes, I have read the Asterisk Issue Guidelines
@jcolp jcolp added support-level-extended Functionality with extended support level and removed triage labels Sep 20, 2023
InterLinked1 added a commit to InterLinked1/asterisk that referenced this issue Dec 23, 2023
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: asterisk#341
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 8, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 8, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 8, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 8, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 12, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
(cherry picked from commit f4edb3b)
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 12, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
(cherry picked from commit 83a0cb5)
asterisk-org-access-app bot pushed a commit that referenced this issue Jan 12, 2024
This fixes faulty branching logic for the
EndIf application. Instead of computing
the next priority, which should be done
for false conditionals or ExitIf, we should
simply advance to the next priority.

Resolves: #341
(cherry picked from commit 1bf4493)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug support-level-extended Functionality with extended support level
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants