1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

client: Added a missing NULL pointer check.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Oliver Stöneberg
2013-10-18 14:57:33 +02:00
committed by Andreas Schneider
parent bec13a6ac0
commit 4c300313c3

View File

@@ -105,14 +105,19 @@ static int callback_receive_banner(const void *data, size_t len, void *user) {
ssh_pcap_context_write(session->pcap_ctx,SSH_PCAP_DIR_IN,buffer,i+1,i+1); ssh_pcap_context_write(session->pcap_ctx,SSH_PCAP_DIR_IN,buffer,i+1,i+1);
} }
#endif #endif
if(buffer[i]=='\r') if(buffer[i]=='\r') {
buffer[i]='\0'; buffer[i]='\0';
if(buffer[i]=='\n'){ }
buffer[i]='\0'; if (buffer[i]=='\n') {
str=strdup(buffer); buffer[i] = '\0';
/* number of bytes read */ str = strdup(buffer);
ret=i+1; if (str == NULL) {
session->serverbanner=str; leave_function();
return SSH_ERROR;
}
/* number of bytes read */
ret = i + 1;
session->serverbanner = str;
session->session_state=SSH_SESSION_STATE_BANNER_RECEIVED; session->session_state=SSH_SESSION_STATE_BANNER_RECEIVED;
SSH_LOG(SSH_LOG_PACKET,"Received banner: %s",str); SSH_LOG(SSH_LOG_PACKET,"Received banner: %s",str);
session->ssh_connection_callback(session); session->ssh_connection_callback(session);