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

Bug in peer_data_storage.c in nRF5 SDK?

Hi,

I found a suspicious line of code.

SDK: nRF5 SDK 13.1.0 (7ca7556)

File: peer_data_storage.c

Function: pds_peer_data_read

At line number: 415

    if ((*p_buf_len) <= data_len_bytes)
    {
        memcpy(p_data->p_all_data, rec_flash.p_data, data_len_bytes);
    }

According to the comment above: "...check that the buffer is large enough and copy the data in flash into the buffer".

The relational operator probably needs to be reversed. ("Is the buffer larger than or equal to the actual size?") For this or that reason, the code should read:

if ((*p_buf_len) >= data_len_bytes)

What do you think?

Related