if_wg: avoid null ptr deref

While we're here, sync up with OpenBSD and don't use a keypair !kp_valid

MFC after:	3 days
This commit is contained in:
Kyle Evans 2021-03-07 20:47:27 -06:00
parent df55485085
commit 2b82c94acf

View File

@ -673,7 +673,7 @@ noise_remote_decrypt(struct noise_remote *r, struct noise_data *data,
* REKEY_AFTER_TIME_RECV seconds. */
ret = ESTALE;
kp = r->r_current;
if (kp->kp_is_initiator &&
if (kp != NULL && kp->kp_valid && kp->kp_is_initiator &&
noise_timer_expired(&kp->kp_birthdate, REKEY_AFTER_TIME_RECV, 0))
goto error;