Add missing NULL pointer checks to crypt_set_algorithms_server.

Thanks to Orange Labs for the report.
This commit is contained in:
Andreas Schneider
2009-09-03 17:20:06 +02:00
parent 8344598910
commit 0792c015d6

View File

@@ -982,12 +982,13 @@ int crypt_set_algorithms_server(SSH_SESSION *session){
server=session->server_kex.methods[SSH_HOSTKEYS]; server=session->server_kex.methods[SSH_HOSTKEYS];
client=session->client_kex.methods[SSH_HOSTKEYS]; client=session->client_kex.methods[SSH_HOSTKEYS];
match=ssh_find_matching(client,server); match=ssh_find_matching(client,server);
if(!strcmp(match,"ssh-dss")) if(match && !strcmp(match,"ssh-dss"))
session->hostkeys=TYPE_DSS; session->hostkeys=TYPE_DSS;
else if(!strcmp(match,"ssh-rsa")) else if(match && !strcmp(match,"ssh-rsa"))
session->hostkeys=TYPE_RSA; session->hostkeys=TYPE_RSA;
else { else {
ssh_set_error(session,SSH_FATAL,"cannot know what %s is into %s",match,server); ssh_set_error(session, SSH_FATAL, "Cannot know what %s is into %s",
match ? match : NULL, server);
free(match); free(match);
leave_function(); leave_function();
return SSH_ERROR; return SSH_ERROR;