@@ -68,6 +68,28 @@ struct static_route_args {
6868 const char * srv6_encap_behavior ;
6969};
7070
71+ /* Reject invalid keywords interpreted as interface names */
72+ static bool staticd_ifname_invalid (const char * ifname )
73+ {
74+ const char * const * cp ;
75+ static const char * const invalid_names [] = {
76+ "tag" ,
77+ "vrf" ,
78+ "label" ,
79+ "color" ,
80+ "table" ,
81+ "segments" ,
82+ "nexthop-vrf" ,
83+ NULL /*End sentinel*/
84+ };
85+
86+ for (cp = invalid_names ; cp != NULL && * cp != NULL ; cp ++ )
87+ if (strmatch (* cp , ifname ))
88+ return true;
89+
90+ return false;
91+ }
92+
7193static int static_route_nb_run (struct vty * vty , struct static_route_args * args )
7294{
7395 int ret ;
@@ -116,10 +138,17 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
116138 if (args -> nexthop_vrf == NULL )
117139 args -> nexthop_vrf = args -> vrf ;
118140
119- if (args -> interface_name &&
120- !strcasecmp (args -> interface_name , "Null0" )) {
121- args -> flag = "Null0" ;
122- args -> interface_name = NULL ;
141+ /* Interface token validation */
142+ if (args -> interface_name ) {
143+ if (strcasecmp (args -> interface_name , "Null0" ) == 0 ) {
144+ args -> flag = "Null0" ;
145+ args -> interface_name = NULL ;
146+ } else if (staticd_ifname_invalid (args -> interface_name )) {
147+ /* Check for prohibited keywords as ifname */
148+ vty_out (vty , "%% Invalid interface name %s\n" ,
149+ args -> interface_name );
150+ return CMD_WARNING_CONFIG_FAILED ;
151+ }
123152 }
124153
125154 assert (!!str2prefix (args -> prefix , & p ));
0 commit comments