mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-17 06:18:58 +03:00
Always check return value of ssh_list_new()
Another item identified during code review was cases where the return value of ssh_list_new() was not properly checked and handled. This updates all cases that were missing this to handle failure to allocate a new list. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
daeee74edd
commit
0987e6065c
@@ -513,24 +513,30 @@ static int ssh_message_termination(void *s){
|
||||
* @warning This function blocks until a message has been received. Betterset up
|
||||
* a callback if this behavior is unwanted.
|
||||
*/
|
||||
ssh_message ssh_message_get(ssh_session session) {
|
||||
ssh_message msg = NULL;
|
||||
int rc;
|
||||
ssh_message ssh_message_get(ssh_session session)
|
||||
{
|
||||
ssh_message msg = NULL;
|
||||
int rc;
|
||||
|
||||
msg=ssh_message_pop_head(session);
|
||||
if(msg) {
|
||||
return msg;
|
||||
}
|
||||
if(session->ssh_message_list == NULL) {
|
||||
session->ssh_message_list = ssh_list_new();
|
||||
}
|
||||
rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
|
||||
ssh_message_termination, session);
|
||||
if(rc || session->session_state == SSH_SESSION_STATE_ERROR)
|
||||
return NULL;
|
||||
msg=ssh_list_pop_head(ssh_message, session->ssh_message_list);
|
||||
msg = ssh_message_pop_head(session);
|
||||
if (msg != NULL) {
|
||||
return msg;
|
||||
}
|
||||
if (session->ssh_message_list == NULL) {
|
||||
session->ssh_message_list = ssh_list_new();
|
||||
if (session->ssh_message_list == NULL) {
|
||||
ssh_set_error_oom(session);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
|
||||
ssh_message_termination, session);
|
||||
if (rc || session->session_state == SSH_SESSION_STATE_ERROR) {
|
||||
return NULL;
|
||||
}
|
||||
msg = ssh_list_pop_head(ssh_message, session->ssh_message_list);
|
||||
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user