libssh  0.8.0
Functions
The SSH buffer functions.

Functions to handle SSH buffers. More...

Functions

int ssh_buffer_add_data (struct ssh_buffer_struct *buffer, const void *data, uint32_t len)
 Add data at the tail of a buffer. More...
 
void ssh_buffer_free (struct ssh_buffer_struct *buffer)
 Deallocate a SSH buffer. More...
 
void * ssh_buffer_get (struct ssh_buffer_struct *buffer)
 Get a pointer to the head of a buffer at the current position. More...
 
uint32_t ssh_buffer_get_data (struct ssh_buffer_struct *buffer, void *data, uint32_t len)
 Get the remaining data out of the buffer and adjust the read pointer. More...
 
uint32_t ssh_buffer_get_len (struct ssh_buffer_struct *buffer)
 Get the length of the buffer from the current position. More...
 
struct ssh_buffer_struct * ssh_buffer_new (void)
 Create a new SSH buffer. More...
 
int ssh_buffer_reinit (struct ssh_buffer_struct *buffer)
 Reinitialize a SSH buffer. More...
 
void ssh_buffer_set_secure (ssh_buffer buffer)
 Sets the buffer as secure. More...
 
int ssh_buffer_validate_length (struct ssh_buffer_struct *buffer, size_t len)
 Valdiates that the given length can be obtained from the buffer. More...
 

Detailed Description

Functions to handle SSH buffers.

Function Documentation

int ssh_buffer_add_data ( struct ssh_buffer_struct *  buffer,
const void *  data,
uint32_t  len 
)

Add data at the tail of a buffer.

Parameters
[in]bufferThe buffer to add the data.
[in]dataA pointer to the data to add.
[in]lenThe length of the data to add.
Returns
0 on success, < 0 on error.

References ssh_buffer_get(), ssh_buffer_get_len(), and ssh_string_len().

Referenced by channel_read_buffer(), sftp_free(), sftp_get_error(), ssh_buffer_validate_length(), ssh_channel_new(), ssh_channel_request_auth_agent(), ssh_channel_set_blocking(), ssh_pki_copy_cert_to_privkey(), and ssh_pki_import_pubkey_base64().

void ssh_buffer_free ( struct ssh_buffer_struct *  buffer)
void* ssh_buffer_get ( struct ssh_buffer_struct *  buffer)

Get a pointer to the head of a buffer at the current position.

Parameters
[in]bufferThe buffer to get the head pointer.
Returns
A pointer to the data from current position.
See also
ssh_buffer_get_len()

Referenced by sftp_free(), sftp_get_error(), ssh_buffer_add_data(), ssh_channel_new(), ssh_channel_read_timeout(), ssh_channel_request_auth_agent(), ssh_channel_set_blocking(), ssh_gssapi_get_creds(), ssh_message_free(), and ssh_pki_copy_cert_to_privkey().

uint32_t ssh_buffer_get_data ( struct ssh_buffer_struct *  buffer,
void *  data,
uint32_t  len 
)

Get the remaining data out of the buffer and adjust the read pointer.

Parameters
[in]bufferThe buffer to read.
[in]dataThe data buffer where to store the data.
[in]lenThe length to read from the buffer.
Returns
0 if there is not enough data in buffer, len otherwise.

References ssh_buffer_validate_length().

Referenced by ssh_buffer_validate_length().

uint32_t ssh_buffer_get_len ( struct ssh_buffer_struct *  buffer)
struct ssh_buffer_struct* ssh_buffer_new ( void  )
int ssh_buffer_reinit ( struct ssh_buffer_struct *  buffer)
void ssh_buffer_set_secure ( ssh_buffer  buffer)

Sets the buffer as secure.

A secure buffer will never leave cleartext data in the heap after being reallocated or freed.

Parameters
[in]bufferbuffer to set secure.

Referenced by ssh_pki_copy_cert_to_privkey().

int ssh_buffer_validate_length ( struct ssh_buffer_struct *  buffer,
size_t  len 
)

Valdiates that the given length can be obtained from the buffer.

Parameters
[in]bufferThe buffer to read from.
[in]lenThe length to be checked.
Returns
SSH_OK if the length is valid, SSH_ERROR otherwise.

References ssh_buffer_add_data(), ssh_buffer_get_data(), ssh_buffer_get_len(), ssh_string_data(), and ssh_string_new().

Referenced by ssh_buffer_get_data().