Skip to content

Commit

Permalink
Remove some unnecessary casts; fix a minor memory leak on error condi…
Browse files Browse the repository at this point in the history
…tions.
  • Loading branch information
tjsaunders committed Aug 13, 2015
1 parent c3f3348 commit b0f7c30
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contrib/mod_sftp/kex.c
Expand Up @@ -2816,19 +2816,20 @@ static int write_dh_gex_reply(struct ssh2_packet *pkt, struct sftp_kex *kex,
buf = palloc(kex_pool, dhlen);

pr_trace_msg(trace_channel, 12, "computing DH key");
res = DH_compute_key((unsigned char *) buf, kex->e, kex->dh);
res = DH_compute_key(buf, kex->e, kex->dh);
if (res < 0) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error computing DH shared secret: %s", sftp_crypto_get_errors());
return -1;
}

k = BN_new();
if (BN_bin2bn((unsigned char *) buf, res, k) == NULL) {
if (BN_bin2bn(buf, res, k) == NULL) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"error converting DH shared secret to BN: %s", sftp_crypto_get_errors());

pr_memscrub(buf, res);
BN_clear_free(k);
return -1;
}

Expand Down

0 comments on commit b0f7c30

Please sign in to comment.