NordicSemiconductor / Android-nRF-Mesh-Library

The Bluetooth Mesh Provisioner and Configurator library.
https://www.nordicsemi.com/
BSD 3-Clause "New" or "Revised" License
414 stars 177 forks source link

Exclusion list filter with empty Address Array ignores messages #466

Closed Eklow02 closed 2 years ago

Eklow02 commented 2 years ago

Describe the bug The DefaultNoOperationMessageState does not process the messages correctly, if the proxy filter EXCLUSION_LIST_FILTER is set with an empty addresses range.

To Reproduce Steps to reproduce the behavior:

  1. Set the Filtertype to EXCLUSION_LIST_FILTER, but don't add any addresses to the array yet.
  2. The method isReceivedViaProxyFilter returns true

Expected behavior If there are no matching addresses the isReceivedViaProxyFilter method should return false.

Platform details:

Possible fix:

private boolean isReceivedViaProxyFilter(@NonNull final Message message) {
        final ProxyFilter filter = mInternalTransportCallbacks.getProxyFilter();
        if (filter != null && !filter.getAddresses().isEmpty()) {
            if (filter.getFilterType().getType() == ProxyFilterType.INCLUSION_LIST_FILTER) {
                return filterAddressMatches(filter, message.getDst());
            } else {
                return !filterAddressMatches(filter, message.getDst());
            }
        }
        return false;
    }
roshanrajaratnam commented 2 years ago

Thanks for catching this.