net: l2: ieee802154: shell: Fix stringop-truncation

- Fix the warning stringop-truncation
- Leave space for NULL terminator.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
This commit is contained in:
Ayush Singh 2024-10-08 21:20:11 +05:30 committed by Alberto Escolar
parent d8f3bfa7a2
commit 5b5d6366e3

View file

@ -79,7 +79,7 @@ static int cmd_ieee802154_associate(const struct shell *sh,
size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_ieee802154();
char ext_addr[EXT_ADDR_STR_SIZE];
char ext_addr[EXT_ADDR_STR_SIZE] = {0};
if (argc < 3) {
shell_help(sh);
@ -99,7 +99,7 @@ static int cmd_ieee802154_associate(const struct shell *sh,
params = (struct ieee802154_req_params){0};
params.pan_id = atoi(argv[1]);
strncpy(ext_addr, argv[2], sizeof(ext_addr));
strncpy(ext_addr, argv[2], EXT_ADDR_STR_LEN);
if (strlen(ext_addr) == EXT_ADDR_STR_LEN) {
if (parse_extended_address(ext_addr, params.addr) < 0) {