libssh  0.7.90
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

◆ ssh_buffer_add_data()

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.

Referenced by channel_read_buffer().

◆ ssh_buffer_free()

void ssh_buffer_free ( struct ssh_buffer_struct *  buffer)

◆ ssh_buffer_get()

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()

◆ ssh_buffer_get_data()

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().

◆ ssh_buffer_get_len()

uint32_t ssh_buffer_get_len ( struct ssh_buffer_struct *  buffer)

Get the length of the buffer from the current position.

Parameters
[in]bufferThe buffer to get the length from.
Returns
The length of the buffer.
See also
ssh_buffer_get()

Referenced by sftp_write(), ssh_channel_is_eof(), ssh_channel_poll(), and ssh_channel_read_timeout().

◆ ssh_buffer_new()

struct ssh_buffer_struct* ssh_buffer_new ( void  )

◆ ssh_buffer_reinit()

int ssh_buffer_reinit ( struct ssh_buffer_struct *  buffer)

Reinitialize a SSH buffer.

Parameters
[in]bufferThe buffer to reinitialize.
Returns
0 on success, < 0 on error.

Referenced by channel_read_buffer().

◆ ssh_buffer_set_secure()

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.

◆ ssh_buffer_validate_length()

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.

Referenced by ssh_buffer_get_data().