Skip to content

Commit

Permalink
tree: ignore false positive ASAN error
Browse files Browse the repository at this point in the history
gcc complains with

In function ‘nvme_ctrl_lookup_phy_slot’,
    inlined from ‘nvme_configure_ctrl’ at ../src/nvme/tree.c:1798:16:
../src/nvme/tree.c:1736:21: error: ‘strncmp’ specified bound 2 exceeds source size 0 [-Werror=stringop-overread]
 1736 |                     strncmp(entry->d_name, "..", 2) != 0) {
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/nvme/tree.c:1748:40: error: ‘strdup’ reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
 1748 |                                 return strdup(entry->d_name);
      |                                        ^~~~~~~~~~~~~~~~~~~~~
In function ‘nvme_configure_ctrl’:

because d_name is defined as d_name[0] in POSIX but on Linux it is
actually d_name[256] and is a valid NULL terminated string.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Dec 19, 2023
1 parent 8d0beda commit 4458f97
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,8 @@ static char *nvme_ctrl_lookup_subsystem_name(nvme_root_t r,
return NULL;
}

#pragma GCC diagnostic ignored "-Wstringop-overread"

static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
{
_cleanup_free_ char *target_addr = NULL;
Expand Down Expand Up @@ -1746,9 +1748,12 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
return strdup(entry->d_name);
}
}

return NULL;
}

#pragma GCC diagnostic pop

static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
const char *name)
{
Expand Down

0 comments on commit 4458f97

Please sign in to comment.