From 937747fd4de64a33bccf5adb73924c435ceb821b Mon Sep 17 00:00:00 2001 From: Alberto Fanjul Date: Sat, 13 Jul 2024 19:14:55 +0200 Subject: [PATCH] control null terminated string copying --- src/shared/wpas.c | 2 +- src/wifi/wifid-peer.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/wpas.c b/src/shared/wpas.c index 171a472..6882431 100644 --- a/src/shared/wpas.c +++ b/src/shared/wpas.c @@ -1054,7 +1054,7 @@ static int wpas__bind_server_socket(int fd, const char *ctrl_path, char *name) } } - strncpy(name, src.sun_path, UNIX_PATH_MAX - 1); + strncpy(name, src.sun_path, UNIX_PATH_MAX); name[UNIX_PATH_MAX - 1] = 0; return 0; diff --git a/src/wifi/wifid-peer.c b/src/wifi/wifid-peer.c index a361089..b87d0cc 100644 --- a/src/wifi/wifid-peer.c +++ b/src/wifi/wifid-peer.c @@ -61,7 +61,8 @@ int peer_new(struct link *l, r = log_ENOMEM(); goto error; } - strncpy(p->p2p_mac, mac, MAC_STRLEN - 1); + strncpy(p->p2p_mac, mac, MAC_STRLEN); + p->p2p_mac[MAC_STRLEN - 1] = 0; r = shl_htable_insert_str(&l->peers, &p->p2p_mac, NULL); if (r < 0) {