Folks,

The following code snippet is not sufficient to check a sw_if_index in a binary 
API message handler:

  hw = vnet_get_sup_hw_interface (vnm, ntohl(mp->sw_if_index));
  if (hw == NULL || <some>_device_class.index != hw->dev_class_index)
    return VNET_API_ERROR_INVALID_SW_IF_INDEX;

If sw_if_index is invalid, a debug image will ASSERT and a production image 
will continue; possibly resulting in a spectacular crash later. 
Vnet_get_sup_hw_interface(...) trusts its sw_if_index argument.

Please either use the VALIDATE_SW_IF_INDEX(...) macro, or use 
vnet_sw_if_index_is_api_valid(...) or some variant thereof to check the 
sw_if_index BEFORE calling vnet_get_sup_hw_interface(...).

Thanks... Dave

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13537): https://lists.fd.io/g/vpp-dev/message/13537
Mute This Topic: https://lists.fd.io/mt/32549075/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to