From 7d32ec5d28ecdf72f69d14794fd2fc98003b3fdd Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Wed, 28 Apr 2010 19:36:39 +0200 Subject: Fix warnings found with clang analyzer --- libssh/dh.c | 2 +- libssh/packet.c | 3 +-- libssh/scp.c | 20 ++++++++++++++++++++ libssh/sftp.c | 6 +++--- 4 files changed, 25 insertions(+), 6 deletions(-) (limited to 'libssh') diff --git a/libssh/dh.c b/libssh/dh.c index 86de9a2d..9b9e129f 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -882,7 +882,7 @@ static int match(const char *group, const char *object){ const char *a; const char *z; - a = z = group; + z = group; do { a = strchr(z, ','); if (a == NULL) { diff --git a/libssh/packet.c b/libssh/packet.c index ad10b496..f0f7b919 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -126,7 +126,7 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user) char buffer[16] = {0}; void *packet=NULL; int to_be_read; - int rc = SSH_ERROR; + int rc; uint32_t len; uint8_t padding; size_t processed=0; /* number of byte processed from the callback */ @@ -187,7 +187,6 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user) /* give up, not enough data in buffer */ return processed; } - rc = SSH_ERROR; packet = (unsigned char *)data + processed; // ssh_socket_read(session->socket,packet,to_be_read-current_macsize); diff --git a/libssh/scp.c b/libssh/scp.c index 52a28091..9590e2d2 100644 --- a/libssh/scp.c +++ b/libssh/scp.c @@ -112,6 +112,11 @@ int ssh_scp_init(ssh_scp scp){ } if(scp->mode == SSH_SCP_WRITE){ r=channel_read(scp->channel,&code,1,0); + if(r<=0){ + ssh_set_error(scp->session,SSH_FATAL, "Error reading status code: %s",ssh_get_error(scp->session)); + scp->state=SSH_SCP_ERROR; + return SSH_ERROR; + } if(code != 0){ ssh_set_error(scp->session,SSH_FATAL, "scp status code %ud not valid", code); scp->state=SSH_SCP_ERROR; @@ -207,6 +212,11 @@ int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode){ return SSH_ERROR; } r=channel_read(scp->channel,&code,1,0); + if(r<=0){ + ssh_set_error(scp->session,SSH_FATAL, "Error reading status code: %s",ssh_get_error(scp->session)); + scp->state=SSH_SCP_ERROR; + return SSH_ERROR; + } if(code != 0){ ssh_set_error(scp->session,SSH_FATAL, "scp status code %ud not valid", code); scp->state=SSH_SCP_ERROR; @@ -239,6 +249,11 @@ int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode){ return SSH_ERROR; } r=channel_read(scp->channel,&code,1,0); + if(r<=0){ + ssh_set_error(scp->session,SSH_FATAL, "Error reading status code: %s",ssh_get_error(scp->session)); + scp->state=SSH_SCP_ERROR; + return SSH_ERROR; + } if(code != 0){ ssh_set_error(scp->session,SSH_FATAL, "scp status code %ud not valid", code); scp->state=SSH_SCP_ERROR; @@ -286,6 +301,11 @@ int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int mode){ return SSH_ERROR; } r=channel_read(scp->channel,&code,1,0); + if(r<=0){ + ssh_set_error(scp->session,SSH_FATAL, "Error reading status code: %s",ssh_get_error(scp->session)); + scp->state=SSH_SCP_ERROR; + return SSH_ERROR; + } if(code != 0){ ssh_set_error(scp->session,SSH_FATAL, "scp status code %ud not valid", code); scp->state=SSH_SCP_ERROR; diff --git a/libssh/sftp.c b/libssh/sftp.c index 82c00341..ca6d64e2 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -2400,9 +2400,9 @@ int sftp_rename(sftp_session sftp, const char *original, const char *newname) { /* Code written by Nick */ /* Set file attributes on a file, directory or symbolic link. */ int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr) { - uint32_t id = sftp_get_new_id(sftp); - ssh_buffer buffer = buffer_new(); - ssh_string path = string_from_char(file); + uint32_t id; + ssh_buffer buffer; + ssh_string path; sftp_message msg = NULL; sftp_status_message status = NULL; -- cgit v1.2.3