Skip to content

Commit

Permalink
invalidate dh->priv_key after freeing it in error path; avoids
Browse files Browse the repository at this point in the history
unlikely double-free later. Reported by Viktor Dukhovni via
openssh/openssh-portable#96
feedback jsing@ tb@
  • Loading branch information
djmdjm committed Aug 4, 2018
1 parent 60f6008 commit c777f7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 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 @@ -275,6 +275,7 @@ dh_gen_key(DH *dh, int need)
if (DH_generate_key(dh) == 0 ||
!dh_pub_is_valid(dh, dh->pub_key)) {
BN_clear_free(dh->priv_key);
dh->priv_key = NULL;
return SSH_ERR_LIBCRYPTO_ERROR;
}
return 0;
Expand Down

0 comments on commit c777f7f

Please sign in to comment.