This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Possible bug in nfc_ble_pair_msg.c

SDK 13 Alpha

Lines 513-528 of nfc_ble_pair_msg.c read as follows:

if(ble_lesc_oob_data != NULL)
{
    if((ble_lesc_oob_data->c != NULL) && (ble_lesc_oob_data->r != NULL))
    {
        memcpy(m_lesc_pos.confirm, ble_lesc_oob_data->c, AD_TYPE_CONFIRM_VALUE_DATA_SIZE);
        memcpy(m_lesc_pos.random, ble_lesc_oob_data->r, AD_TYPE_RANDOM_VALUE_DATA_SIZE);
    
        return NRF_SUCCESS;            
    }
    
    return NRF_ERROR_INVALID_STATE;
}
else
{
    return NRF_ERROR_NULL;
}      

(Here's the definition of ble_gap_lesc_oob_data_t:)

/**@brief GAP LE Secure Connections OOB data. */
typedef struct
{
  ble_gap_addr_t  addr;                          /**< Bluetooth address of the device. */
  uint8_t         r[BLE_GAP_SEC_KEY_LEN];        /**< Random Number. */
  uint8_t         c[BLE_GAP_SEC_KEY_LEN];        /**< Confirm Value. */
} ble_gap_lesc_oob_data_t;

The second if statement is checking whether array members of the struct are non-null. Because these are arrays and not pointers they can never be null. It is unclear to me whether this second if should just be removed, or if it's really trying to check if the contents of c and r are non-null and needs to be changed. It seems like it might be trying to check if the contents are non-null because the error code for failure there is INVALID_STATE instead of NULL.

Thanks!

Related