mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-27 13:21:11 +03:00
buffer: add a hidden canary to detect format errors
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
committed by
Andreas Schneider
parent
7bd62dd652
commit
3b4b0f01ec
@@ -38,6 +38,8 @@ struct ssh_buffer_struct {
|
||||
uint32_t pos;
|
||||
};
|
||||
|
||||
#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
|
||||
|
||||
LIBSSH_API void ssh_buffer_free(ssh_buffer buffer);
|
||||
LIBSSH_API void *ssh_buffer_get_begin(ssh_buffer buffer);
|
||||
LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer);
|
||||
@@ -49,9 +51,12 @@ int buffer_add_u32(ssh_buffer buffer, uint32_t data);
|
||||
int buffer_add_u64(ssh_buffer buffer, uint64_t data);
|
||||
int ssh_buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
|
||||
int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer, const char *format, va_list ap);
|
||||
int ssh_buffer_pack(struct ssh_buffer_struct *buffer, const char *format, ...);
|
||||
int _ssh_buffer_pack(struct ssh_buffer_struct *buffer, const char *format, ...);
|
||||
#define ssh_buffer_pack(buffer, format, ...) _ssh_buffer_pack((buffer),(format), __VA_ARGS__, SSH_BUFFER_PACK_END)
|
||||
int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer, const char *format, va_list ap);
|
||||
int ssh_buffer_unpack(struct ssh_buffer_struct *buffer, const char *format, ...);
|
||||
int _ssh_buffer_unpack(struct ssh_buffer_struct *buffer, const char *format, ...);
|
||||
#define ssh_buffer_unpack(buffer, format, ...) _ssh_buffer_unpack((buffer),(format), __VA_ARGS__, SSH_BUFFER_PACK_END)
|
||||
|
||||
int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
|
||||
int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
||||
int ssh_buffer_reinit(ssh_buffer buffer);
|
||||
|
||||
Reference in New Issue
Block a user