Commit f4c6ca8c authored by Ondřej Zajíček's avatar Ondřej Zajíček
Browse files

Fixes preference bounds.

parent 0781e9c6
...@@ -724,7 +724,7 @@ defined by using the <cf>defined( <m>attribute</m> )</cf> operator. ...@@ -724,7 +724,7 @@ defined by using the <cf>defined( <m>attribute</m> )</cf> operator.
Address scope of the network (<cf/SCOPE_HOST/ for addresses local to this host, <cf/SCOPE_LINK/ for those specific for a physical link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private addresses, <cf/SCOPE_UNIVERSE/ for globally visible addresses). Address scope of the network (<cf/SCOPE_HOST/ for addresses local to this host, <cf/SCOPE_LINK/ for those specific for a physical link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private addresses, <cf/SCOPE_UNIVERSE/ for globally visible addresses).
<tag><m/int/ preference</tag> <tag><m/int/ preference</tag>
Preference of the route. (See the chapter about routing tables.) Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.)
<tag><m/ip/ from</tag> <tag><m/ip/ from</tag>
The router which the route has originated from. Read-only. The router which the route has originated from. Read-only.
......
...@@ -702,6 +702,8 @@ interpret(struct f_inst *what) ...@@ -702,6 +702,8 @@ interpret(struct f_inst *what)
ONEARG; ONEARG;
if (v1.type != T_INT) if (v1.type != T_INT)
runtime( "Can't set preference to non-integer" ); runtime( "Can't set preference to non-integer" );
if ((v1.val.i < 0) || (v1.val.i > 0xFFFF))
runtime( "Setting preference value out of bounds" );
*f_rte = rte_cow(*f_rte); *f_rte = rte_cow(*f_rte);
(*f_rte)->pref = v1.val.i; (*f_rte)->pref = v1.val.i;
break; break;
......
...@@ -132,7 +132,7 @@ proto_name: ...@@ -132,7 +132,7 @@ proto_name:
proto_item: proto_item:
/* EMPTY */ /* EMPTY */
| PREFERENCE expr { | PREFERENCE expr {
if ($2 < 0 || $2 > 255) cf_error("Invalid preference"); if ($2 < 0 || $2 > 0xFFFF) cf_error("Invalid preference");
this_proto->preference = $2; this_proto->preference = $2;
} }
| DISABLED bool { this_proto->disabled = $2; } | DISABLED bool { this_proto->disabled = $2; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment