1
1

dh: harden error handling in 'ssh_dh_init_common'

Harden the error path in 'ssh_dh_init_common' such that
all potential allocations are free'd upon exit.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Jon Simons 2019-01-29 20:25:13 -05:00 коммит произвёл Andreas Schneider
родитель 3334443089
Коммит 3760e59c13

Просмотреть файл

@ -350,6 +350,9 @@ int ssh_dh_init_common(ssh_session session){
break; break;
} }
if (crypto->x == NULL || crypto->y == NULL || crypto->k == NULL){ if (crypto->x == NULL || crypto->y == NULL || crypto->k == NULL){
bignum_safe_free(crypto->k);
bignum_safe_free(crypto->y);
bignum_safe_free(crypto->x);
ssh_set_error_oom(session); ssh_set_error_oom(session);
return SSH_ERROR; return SSH_ERROR;
} else { } else {