diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-22 23:07:51 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-22 23:07:51 -0600 |
commit | 5a6c97af1e4ef9cfb5ee287ee1c21474c41f1807 (patch) | |
tree | f8485e30bd86b10b4a1566d20ea596c153afed67 | |
parent | wg_noise: zero out new structures (diff) | |
download | wireguard-freebsd-5a6c97af1e4ef9cfb5ee287ee1c21474c41f1807.tar.xz wireguard-freebsd-5a6c97af1e4ef9cfb5ee287ee1c21474c41f1807.zip |
if_wg: zero out remaining mallocs
We might add locks and things later. Mainly it doesn't cost much and
makes things easier/safer to reason about.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/if_wg.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/if_wg.c b/src/if_wg.c index dc6e7e4..1c56ccc 100644 --- a/src/if_wg.c +++ b/src/if_wg.c @@ -405,7 +405,7 @@ wg_peer_alloc(struct wg_softc *sc, const uint8_t pub_key[WG_KEY_SIZE]) sx_assert(&sc->sc_lock, SX_XLOCKED); - if ((peer = malloc(sizeof(*peer), M_WG, M_NOWAIT|M_ZERO)) == NULL) + if ((peer = malloc(sizeof(*peer), M_WG, M_NOWAIT | M_ZERO)) == NULL) goto free_none; if ((peer->p_remote = noise_remote_alloc(sc->sc_local, peer, pub_key)) == NULL) @@ -2232,7 +2232,7 @@ wgc_set(struct wg_softc *sc, struct wg_data_io *wgd) if (wgd->wgd_size >= UINT32_MAX / 2) return (E2BIG); - if ((nvlpacked = malloc(wgd->wgd_size, M_TEMP, M_NOWAIT)) == NULL) + if ((nvlpacked = malloc(wgd->wgd_size, M_TEMP, M_NOWAIT | M_ZERO)) == NULL) return (ENOMEM); sx_xlock(&sc->sc_lock); @@ -2601,10 +2601,10 @@ wg_clone_create(struct if_clone *ifc, int unit, caddr_t params) if ((sc->sc_local = noise_local_alloc(sc)) == NULL) goto free_sc; - if ((sc->sc_encrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT)) == NULL) + if ((sc->sc_encrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT | M_ZERO)) == NULL) goto free_local; - if ((sc->sc_decrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT)) == NULL) + if ((sc->sc_decrypt = mallocarray(sizeof(struct grouptask), mp_ncpus, M_WG, M_NOWAIT | M_ZERO)) == NULL) goto free_encrypt; if (!rn_inithead((void **)&sc->sc_aip4, offsetof(struct aip_addr, in) * NBBY)) |