]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Explicit nul termination of the generated passphrase
authorJouni Malinen <j@w1.fi>
Sat, 7 May 2022 20:58:03 +0000 (23:58 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 7 May 2022 20:59:23 +0000 (23:59 +0300)
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 <j@w1.fi>
src/p2p/p2p.c

index 598a449c11b2a2575bc1e9a5d048c9bdf7caa89b..14eacf946ea85f1936957fd174c524da4e9540cf 100644 (file)
@@ -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) {