mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Add memory error checks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@375 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -214,7 +214,7 @@ extern char *supported_methods[];
|
|||||||
static int server_set_kex(SSH_SESSION * session) {
|
static int server_set_kex(SSH_SESSION * session) {
|
||||||
KEX *server = &session->server_kex;
|
KEX *server = &session->server_kex;
|
||||||
SSH_OPTIONS *options = session->options;
|
SSH_OPTIONS *options = session->options;
|
||||||
int i;
|
int i, j;
|
||||||
char *wanted;
|
char *wanted;
|
||||||
memset(server,0,sizeof(KEX));
|
memset(server,0,sizeof(KEX));
|
||||||
// the program might ask for a specific cookie to be sent. useful for server
|
// the program might ask for a specific cookie to be sent. useful for server
|
||||||
@@ -239,6 +239,13 @@ static int server_set_kex(SSH_SESSION * session) {
|
|||||||
if (!(wanted = options->wanted_methods[i]))
|
if (!(wanted = options->wanted_methods[i]))
|
||||||
wanted = supported_methods[i];
|
wanted = supported_methods[i];
|
||||||
server->methods[i] = strdup(wanted);
|
server->methods[i] = strdup(wanted);
|
||||||
|
if (server->methods[i] == NULL) {
|
||||||
|
for (j = i - 1; j <= 0; j--) {
|
||||||
|
SAFE_FREE(server->methods[j]);
|
||||||
|
}
|
||||||
|
SAFE_FREE(server->methods);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
//printf("server->methods[%d]=%s\n",i,wanted);
|
//printf("server->methods[%d]=%s\n",i,wanted);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user