Using Packet-Src-IP-Address in a switch statement #804

Closed
qnet-herwin opened this Issue Oct 1, 2014 · 1 comment

Projects

None yet

2 participants

@qnet-herwin
Contributor
switch "%{Packet-Src-IP-Address}" {
  ..
}

A construction like this would result in a call to default case statement, even if other statements should match.

The problem occurs in the if-statement at https://github.com/FreeRADIUS/freeradius-server/blob/master/src/main/modcall.c#L829-L846 The string "%{Packet-Src-IP-Address}" would satisfy the compare instruction g->vpt->type == TMPL_TYPE_ATTR. (Using a string like "foo%{Packet-Src-IP-Address}"would make it a TMPL_TYPE_XLAT_STRUCT). The if-statements concludes that the attribute does not exist, thus you'll end up in the default case.

@alandekok alandekok closed this in 3a1099d Oct 1, 2014
@alandekok
Member

The real fix is to not make the change from expansion -> attribute reference in the first place.

The bug was actually in multiple portions of the code, not just switch. Fixing it in the conversion function means that the bug is fixed everywhere.

@pwdng pwdng added a commit to pwdng/freeradius-server that referenced this issue Oct 24, 2014
@alandekok @pwdng alandekok + pwdng Don't optimize %{virtual} to &Virtual. Closes #804 8dc228c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment