From 4537fe124a1e1c163b6590221c207f128c47902c Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 7 May 2022 23:58:03 +0300 Subject: [PATCH] P2P: Explicit nul termination of the generated passphrase Nul terminate the struct p2p_go_neg_results::passphrase explicitly to keep static analyzers happier. This was already nul terminated in practice due to the full array being cleared to zero on initialization, but that was apparently not clear enough for some analyzers. Signed-off-by: Jouni Malinen --- src/p2p/p2p.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 598a449c1..14eacf946 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1797,6 +1797,7 @@ int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params) p2p->ssid_set = 0; p2p_random(params->passphrase, p2p->cfg->passphrase_len); + params->passphrase[p2p->cfg->passphrase_len] = '\0'; return 0; } @@ -1829,6 +1830,7 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer) os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); res.ssid_len = p2p->ssid_len; p2p_random(res.passphrase, p2p->cfg->passphrase_len); + res.passphrase[p2p->cfg->passphrase_len] = '\0'; } else { res.freq = peer->oper_freq; if (p2p->ssid_len) { -- 2.47.2