From: Jouni Malinen Date: Sat, 7 May 2022 20:58:03 +0000 (+0300) Subject: P2P: Explicit nul termination of the generated passphrase X-Git-Tag: hostap_2_11~1926 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4537fe124a1e1c163b6590221c207f128c47902c;p=thirdparty%2Fhostap.git 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 --- 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) {