mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
dh: Avoid segmentation fault in GEX if fallback to known moduli
Make ssh_fallback_group() to duplicate the modulus and generator. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
7656911953
commit
01f4040218
16
src/dh.c
16
src/dh.c
@@ -571,13 +571,21 @@ int ssh_fallback_group(uint32_t pmax,
|
||||
*generator = NULL;
|
||||
|
||||
if (pmax < 3072) {
|
||||
*modulus = ssh_dh_group14;
|
||||
bignum_dup(ssh_dh_group14, modulus);
|
||||
} else if (pmax < 6144) {
|
||||
*modulus = ssh_dh_group16;
|
||||
bignum_dup(ssh_dh_group16, modulus);
|
||||
} else {
|
||||
*modulus = ssh_dh_group18;
|
||||
bignum_dup(ssh_dh_group18, modulus);
|
||||
}
|
||||
if (*modulus == NULL) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
bignum_dup(ssh_dh_generator, generator);
|
||||
if (*generator == NULL) {
|
||||
bignum_safe_free((*modulus));
|
||||
return SSH_ERROR;
|
||||
}
|
||||
*generator = ssh_dh_generator;
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user