diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-10-07 14:08:17 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-10-07 14:08:17 +0200 |
commit | 763359f6b6e1b0c58363c715d2e49e43b2838edc (patch) | |
tree | c7a23e067268f7f21360feca1acdd45fe9a5d42a | |
parent | 43a40999da17cd163b966ee096e9f76f9646f10a (diff) | |
download | libssh-763359f6b6e1b0c58363c715d2e49e43b2838edc.tar.gz libssh-763359f6b6e1b0c58363c715d2e49e43b2838edc.tar.xz libssh-763359f6b6e1b0c58363c715d2e49e43b2838edc.zip |
sftp: Reformat sftp_packet_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | src/sftp.c | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -318,32 +318,33 @@ void sftp_free(sftp_session sftp) SAFE_FREE(sftp); } -int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload){ - int size; +int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload) +{ + int size; - if (ssh_buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) { - ssh_set_error_oom(sftp->session); - return -1; - } + if (ssh_buffer_prepend_data(payload, &type, sizeof(uint8_t)) < 0) { + ssh_set_error_oom(sftp->session); + return -1; + } - size = htonl(ssh_buffer_get_len(payload)); - if (ssh_buffer_prepend_data(payload, &size, sizeof(uint32_t)) < 0) { - ssh_set_error_oom(sftp->session); - return -1; - } + size = htonl(ssh_buffer_get_len(payload)); + if (ssh_buffer_prepend_data(payload, &size, sizeof(uint32_t)) < 0) { + ssh_set_error_oom(sftp->session); + return -1; + } - size = ssh_channel_write(sftp->channel, ssh_buffer_get(payload), - ssh_buffer_get_len(payload)); - if (size < 0) { - return -1; - } else if((uint32_t) size != ssh_buffer_get_len(payload)) { - SSH_LOG(SSH_LOG_PACKET, - "Had to write %d bytes, wrote only %d", - ssh_buffer_get_len(payload), - size); - } + size = ssh_channel_write(sftp->channel, ssh_buffer_get(payload), + ssh_buffer_get_len(payload)); + if (size < 0) { + return -1; + } else if((uint32_t) size != ssh_buffer_get_len(payload)) { + SSH_LOG(SSH_LOG_PACKET, + "Had to write %d bytes, wrote only %d", + ssh_buffer_get_len(payload), + size); + } - return size; + return size; } sftp_packet sftp_packet_read(sftp_session sftp) |