aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-10-07 14:08:17 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-10-07 14:08:17 +0200
commit763359f6b6e1b0c58363c715d2e49e43b2838edc (patch)
treec7a23e067268f7f21360feca1acdd45fe9a5d42a
parent43a40999da17cd163b966ee096e9f76f9646f10a (diff)
downloadlibssh-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.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/sftp.c b/src/sftp.c
index 6e6b4c67..0139b617 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -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)