diff options
-rw-r--r-- | include/libssh/priv.h | 2 | ||||
-rw-r--r-- | libssh/buffer.c | 3 | ||||
-rw-r--r-- | libssh/packet.c | 8 | ||||
-rw-r--r-- | libssh/sftp.c | 8 |
4 files changed, 13 insertions, 8 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 8cf1284..c54edef 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -617,7 +617,7 @@ int buffer_add_u8(BUFFER *buffer, u8 data); int buffer_add_u32(BUFFER *buffer, u32 data); int buffer_add_u64(BUFFER *buffer, u64 data); int buffer_add_data(BUFFER *buffer, const void *data, u32 len); -int buffer_add_data_begin(BUFFER *buffer, const void *data, u32 len); +int buffer_prepend_data(BUFFER *buffer, const void *data, u32 len); int buffer_add_buffer(BUFFER *buffer, BUFFER *source); int buffer_reinit(BUFFER *buffer); diff --git a/libssh/buffer.c b/libssh/buffer.c index 32a1f5b..9b8d6ad 100644 --- a/libssh/buffer.c +++ b/libssh/buffer.c @@ -184,7 +184,8 @@ int buffer_add_u8(struct buffer_struct *buffer,u8 data){ * \param len length of data * \return 0 on success, -1 on error. */ -int buffer_add_data_begin(struct buffer_struct *buffer, const void *data, u32 len) { +int buffer_prepend_data(struct buffer_struct *buffer, const void *data, + u32 len) { if (buffer->allocated < (buffer->used + len)) { if (realloc_buffer(buffer, buffer->used + len) < 0) { return -1; diff --git a/libssh/packet.c b/libssh/packet.c index c2435ed..0655257 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -471,10 +471,10 @@ static int packet_send2(SSH_SESSION *session) { "%d bytes after comp + %d padding bytes = %d bytes packet", currentlen, padding, (ntohl(finallen))); - if (buffer_add_data_begin(session->out_buffer, &padding, sizeof(u8)) < 0) { + if (buffer_prepend_data(session->out_buffer, &padding, sizeof(u8)) < 0) { goto error; } - if (buffer_add_data_begin(session->out_buffer, &finallen, sizeof(u32)) < 0) { + if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) { goto error; } if (buffer_add_data(session->out_buffer, padstring, padding) < 0) { @@ -536,10 +536,10 @@ static int packet_send1(SSH_SESSION *session) { "%d bytes after comp + %d padding bytes = %d bytes packet", currentlen, padding, ntohl(finallen)); - if (buffer_add_data_begin(session->out_buffer,i &padstring, padding) < 0) { + if (buffer_prepend_data(session->out_buffer,i &padstring, padding) < 0) { goto error; } - if (buffer_add_data_begin(session->out_buffer, &finallen, sizeof(u32)) < 0) { + if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) { goto error; } diff --git a/libssh/sftp.c b/libssh/sftp.c index 4098b90..35b20b5 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -191,9 +191,13 @@ void sftp_free(SFTP_SESSION *sftp){ int sftp_packet_write(SFTP_SESSION *sftp,u8 type, BUFFER *payload){ int size; - buffer_add_data_begin(payload,&type,sizeof(u8)); + if (buffer_prepend_data(payload, &type, sizeof(u8)) < 0) { + return -1; + } size=htonl(buffer_get_len(payload)); - buffer_add_data_begin(payload,&size,sizeof(u32)); + if (buffer_prepend_data(payload, &size, sizeof(u32)) < 0) { + return -1; + } size=channel_write(sftp->channel,buffer_get(payload),buffer_get_len(payload)); if (size < 0) { return -1; |