hostkey.c: fix invalid memory access if libssh2_dsa_new fails
Reported by dimmaq, fixes #66
This commit is contained in:
parent
51dcded3eb
commit
036196b0b0
@ -274,6 +274,8 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
|||||||
libssh2_dsa_ctx *dsactx;
|
libssh2_dsa_ctx *dsactx;
|
||||||
const unsigned char *p, *q, *g, *y, *s;
|
const unsigned char *p, *q, *g, *y, *s;
|
||||||
unsigned long p_len, q_len, g_len, y_len, len;
|
unsigned long p_len, q_len, g_len, y_len, len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
(void) hostkey_data_len;
|
(void) hostkey_data_len;
|
||||||
|
|
||||||
if (*abstract) {
|
if (*abstract) {
|
||||||
@ -306,7 +308,11 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
|||||||
y = s;
|
y = s;
|
||||||
/* s += y_len; */
|
/* s += y_len; */
|
||||||
|
|
||||||
_libssh2_dsa_new(&dsactx, p, p_len, q, q_len, g, g_len, y, y_len, NULL, 0);
|
ret = _libssh2_dsa_new(&dsactx, p, p_len, q, q_len,
|
||||||
|
g, g_len, y, y_len, NULL, 0);
|
||||||
|
if (ret) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*abstract = dsactx;
|
*abstract = dsactx;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user