interface: fix check in set_interface_name api
set_interface_name may crash if wrong sw_if_index is passed e.g. ~0 Type: fix Signed-off-by: Stanislav Zaikin <stanislav.zaikin@46labs.com> Change-Id: Ic7e400c914fb33c2f9eac4f2985bb5b163a18d57
This commit is contained in:

committed by
Beno�t Ganne

parent
616201abe2
commit
51e6c0d5fe
@ -1020,21 +1020,19 @@ vl_api_sw_interface_set_interface_name_t_handler (
|
||||
{
|
||||
vl_api_sw_interface_set_interface_name_reply_t *rmp;
|
||||
vnet_main_t *vnm = vnet_get_main ();
|
||||
u32 sw_if_index = ntohl (mp->sw_if_index);
|
||||
vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
|
||||
clib_error_t *error;
|
||||
int rv = 0;
|
||||
|
||||
VALIDATE_SW_IF_INDEX (mp);
|
||||
|
||||
u32 sw_if_index = ntohl (mp->sw_if_index);
|
||||
vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
|
||||
|
||||
if (mp->name[0] == 0)
|
||||
{
|
||||
rv = VNET_API_ERROR_INVALID_VALUE;
|
||||
goto out;
|
||||
}
|
||||
if (si == 0)
|
||||
{
|
||||
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = vnet_rename_interface (vnm, si->hw_if_index, (char *) mp->name);
|
||||
if (error)
|
||||
@ -1044,6 +1042,7 @@ vl_api_sw_interface_set_interface_name_t_handler (
|
||||
}
|
||||
|
||||
out:
|
||||
BAD_SW_IF_INDEX_LABEL;
|
||||
REPLY_MACRO (VL_API_SW_INTERFACE_SET_INTERFACE_NAME_REPLY);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user