Skip to content

Commit

Permalink
upstream: invalidate dh->priv_key after freeing it in error path;
Browse files Browse the repository at this point in the history
avoids unlikely double-free later. Reported by Viktor Dukhovni via
openssh#96 feedback jsing@ tb@

OpenBSD-Commit-ID: e317eb17c3e05500ae851f279ef6486f0457c805
  • Loading branch information
djmdjm authored and cotequeiroz committed Aug 29, 2018
1 parent aa88dd1 commit 0cb5511
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions dh.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: dh.c,v 1.65 2018/06/26 11:23:59 millert Exp $ */
/* $OpenBSD: dh.c,v 1.66 2018/08/04 00:55:06 djm Exp $ */
/*
* Copyright (c) 2000 Niels Provos. All rights reserved.
*
Expand Down Expand Up @@ -283,9 +283,8 @@ dh_gen_key(DH *dh, int need)
if (DH_generate_key(dh) == 0)
return SSH_ERR_LIBCRYPTO_ERROR;
DH_get0_key(dh, &pub_key, NULL);
if (!dh_pub_is_valid(dh, pub_key)) {
if (!dh_pub_is_valid(dh, pub_key))
return SSH_ERR_LIBCRYPTO_ERROR;
}
return 0;
}

Expand Down

0 comments on commit 0cb5511

Please sign in to comment.