OpenVPN
|
#include "syshead.h"
#include "common.h"
#include "buffer.h"
#include "error.h"
#include "mtu.h"
#include "misc.h"
#include "memdbg.h"
#include <wchar.h>
Go to the source code of this file.
Macros | |
#define | buf_debug_line(buf) 0 |
#define | buf_debug_file(buf) "[UNDEF]" |
Functions | |
size_t | array_mult_safe (const size_t m1, const size_t m2, const size_t extra) |
void | buf_size_error (const size_t size) |
struct buffer | alloc_buf (size_t size) |
struct buffer | alloc_buf_gc (size_t size, struct gc_arena *gc) |
struct buffer | clone_buf (const struct buffer *buf) |
void | buf_clear (struct buffer *buf) |
bool | buf_assign (struct buffer *dest, const struct buffer *src) |
void | free_buf (struct buffer *buf) |
static void | free_buf_gc (struct buffer *buf, struct gc_arena *gc) |
struct buffer | buf_sub (struct buffer *buf, int size, bool prepend) |
bool | buf_printf (struct buffer *buf, const char *format,...) |
bool | buf_puts (struct buffer *buf, const char *str) |
bool | openvpn_snprintf (char *str, size_t size, const char *format,...) |
bool | openvpn_swprintf (wchar_t *const str, const size_t size, const wchar_t *const format,...) |
void | buf_catrunc (struct buffer *buf, const char *str) |
void | convert_to_one_line (struct buffer *buf) |
bool | buffer_write_file (const char *filename, const struct buffer *buf) |
Write buffer contents to file. More... | |
void * | gc_malloc (size_t size, bool clear, struct gc_arena *a) |
void | x_gc_free (struct gc_arena *a) |
void | x_gc_freespecial (struct gc_arena *a) |
void | gc_addspecial (void *addr, void(*free_function)(void *), struct gc_arena *a) |
void | gc_transfer (struct gc_arena *dest, struct gc_arena *src) |
char * | format_hex_ex (const uint8_t *data, int size, int maxoutput, unsigned int space_break_flags, const char *separator, struct gc_arena *gc) |
void | buf_rmtail (struct buffer *buf, uint8_t remove) |
void | buf_null_terminate (struct buffer *buf) |
void | buf_chomp (struct buffer *buf) |
const char * | skip_leading_whitespace (const char *str) |
void | string_null_terminate (char *str, int len, int capacity) |
void | chomp (char *str) |
void | rm_trailing_chars (char *str, const char *what_to_delete) |
char * | string_alloc (const char *str, struct gc_arena *gc) |
void | string_clear (char *str) |
int | string_array_len (const char **array) |
char * | print_argv (const char **p, struct gc_arena *gc, const unsigned int flags) |
struct buffer | string_alloc_buf (const char *str, struct gc_arena *gc) |
bool | buf_string_match_head_str (const struct buffer *src, const char *match) |
bool | buf_string_compare_advance (struct buffer *src, const char *match) |
int | buf_substring_len (const struct buffer *buf, int delim) |
bool | buf_parse (struct buffer *buf, const int delim, char *line, const int size) |
const char * | np (const char *str) |
bool | char_class (const unsigned char c, const unsigned int flags) |
static bool | char_inc_exc (const char c, const unsigned int inclusive, const unsigned int exclusive) |
bool | string_class (const char *str, const unsigned int inclusive, const unsigned int exclusive) |
bool | string_mod (char *str, const unsigned int inclusive, const unsigned int exclusive, const char replace) |
const char * | string_mod_const (const char *str, const unsigned int inclusive, const unsigned int exclusive, const char replace, struct gc_arena *gc) |
void | string_replace_leading (char *str, const char match, const char replace) |
struct buffer_list * | buffer_list_new (const int max_size) |
Allocate an empty buffer list of capacity max_size . More... | |
void | buffer_list_free (struct buffer_list *ol) |
Frees a buffer list and all the buffers in it. More... | |
bool | buffer_list_defined (const struct buffer_list *ol) |
Checks if the list is valid and non-empty. More... | |
void | buffer_list_reset (struct buffer_list *ol) |
Empty the list ol and frees all the contained buffers. More... | |
void | buffer_list_push (struct buffer_list *ol, const char *str) |
Allocates and appends a new buffer containing str as data to ol . More... | |
struct buffer_entry * | buffer_list_push_data (struct buffer_list *ol, const void *data, size_t size) |
Allocates and appends a new buffer containing data of length size . More... | |
struct buffer * | buffer_list_peek (struct buffer_list *ol) |
Retrieve the head buffer. More... | |
void | buffer_list_aggregate_separator (struct buffer_list *bl, const size_t max_len, const char *sep) |
Aggregates as many buffers as possible from bl in a new buffer of maximum length max_len . More... | |
void | buffer_list_aggregate (struct buffer_list *bl, const size_t max) |
Aggregates as many buffers as possible from bl in a new buffer of maximum length max_len . More... | |
void | buffer_list_pop (struct buffer_list *ol) |
void | buffer_list_advance (struct buffer_list *ol, int n) |
struct buffer_list * | buffer_list_file (const char *fn, int max_line_len) |
struct buffer | buffer_read_from_file (const char *filename, struct gc_arena *gc) |
buffer_read_from_file - copy the content of a file into a buffer More... | |
#define buf_debug_file | ( | buf | ) | "[UNDEF]" |
Definition at line 159 of file buffer.c.
Referenced by clone_buf(), and string_replace_leading().
#define buf_debug_line | ( | buf | ) | 0 |
Definition at line 158 of file buffer.c.
Referenced by clone_buf(), and string_replace_leading().
struct buffer alloc_buf | ( | size_t | size | ) |
Definition at line 64 of file buffer.c.
References buf_size_error(), buf_size_valid(), buffer::capacity, check_malloc_return(), buffer::data, buffer::len, and buffer::offset.
Referenced by alloc_buf_sock_tun(), auth_token_init_secret(), buffer_list_aggregate_separator(), buffer_list_push_data(), check_inline_file(), command_line_new(), fragment_frame_init(), fragment_list_buf_init(), init_context_buffers(), key_state_init(), management_query_cert(), management_query_pk_sig(), mutate_ncp_cipher_list(), openvpn_PRF(), options_string(), read_inline_file(), reliable_init(), send_line_crlf(), status_open(), stream_buf_init(), test_tls_crypt_setup(), tls_crypt_v2_extract_client_key(), tls_crypt_v2_init_client_key(), tls_session_init(), tun_show_debug(), and tuntap_dhcp_mask().
Definition at line 90 of file buffer.c.
References buf_size_error(), buf_size_valid(), buffer::capacity, buffer::data, gc_malloc(), buffer::len, and buffer::offset.
Referenced by __wrap_buffer_read_from_file(), add_option(), buffer_read_from_file(), ce_management_query_proxy(), ce_management_query_remote(), check_incoming_control_channel(), construct_name_value(), crypto_pem_encode(), foreign_option(), fork_dhcp_action(), fork_register_dns_action(), format_common_name(), format_hex_ex(), format_ip_addr_string(), format_route_entry(), frame_print(), generate_auth_token(), get_device_guid(), get_device_instance_id_interface(), get_unspecified_device_guid(), get_user_pass_cr(), hostname_randomize(), ifconfig_options_string(), ifconfig_pool_read(), ipset2ascii_all(), link_socket_connection_initiated(), log_entry_print(), management_callback_send_cc_message(), management_hold(), management_notify_client_cr_response(), management_query_multiline(), management_query_user_pass(), mroute_addr_print_ex(), mroute_helper_regenerate(), msg_flags_string(), multi_instance_string(), netsh_get_id(), ntlm_phase_1(), open_null(), options_string_compat_lzo(), options_string_version(), options_warning_safe_ml(), p2p_mode_ncp(), packet_id_net_print(), packet_id_persist_print(), platform_gen_path(), plugin_mask_string(), prepend_dir(), print_argv(), print_default_gateway(), print_in6_addr(), print_in_addr_t(), print_key_id(), print_link_socket_actual_ex(), print_netmask(), print_opt_route(), print_opt_route_gateway(), print_opt_route_gateway_dhcp(), print_opt_topology(), print_sockaddr_ex(), print_str(), print_str_int(), proto2ascii_all(), protocol_dump(), push_peer_info(), read_control_auth(), reliable_ack_print(), reliable_print_ids(), route_quota_exceeded(), route_string(), send_auth_failed(), send_auth_pending_messages(), send_push_reply(), send_push_reply_auth_token(), server_pushed_info(), setenv_format_indexed_name(), setenv_route(), setenv_route_addr(), setenv_route_ipv6(), socket_stat(), strerror_win32(), system_error_message(), tap_win_getinfo(), test_buffer_free_gc_one(), test_buffer_free_gc_two(), test_crypto(), test_tls_crypt_v2_setup(), time_string(), tls_crypt_v2_wrap_client_key(), tls_crypt_v2_wrap_unwrap_dst_too_small(), tls_crypt_v2_wrap_unwrap_max_metadata(), tls_crypt_v2_wrap_unwrap_no_metadata(), tls_crypt_v2_write_client_key_file(), translate_mtu_discover_type_name(), tun_stat(), tv_string(), username_password_as_base64(), verify_cert(), wide_cmd_line(), win32_version_string(), window_title_generate(), write_key_file(), x509_get_sha1_fingerprint(), and x509_get_sha256_fingerprint().
size_t array_mult_safe | ( | const size_t | m1, |
const size_t | m2, | ||
const size_t | extra | ||
) |
Definition at line 175 of file buffer.c.
References BLEN, BPTR, buf_init, buf_write(), and buffer::offset.
Referenced by buffer_turnover().
void buf_catrunc | ( | struct buffer * | buf, |
const char * | str | ||
) |
Definition at line 338 of file buffer.c.
References buf_forward_capacity(), buf_forward_capacity_total(), buffer::capacity, buffer::data, buffer::len, and strncpynt().
Referenced by format_hex_ex(), and secure_memzero().
void buf_chomp | ( | struct buffer * | buf | ) |
Definition at line 590 of file buffer.c.
References BLAST, buf_inc_len(), buf_null_terminate(), CC_CRLF, CC_NULL, and char_class().
Referenced by command_line_get(), key_state_check_auth_pending_file(), and secure_memzero().
void buf_clear | ( | struct buffer * | buf | ) |
Definition at line 164 of file buffer.c.
References buffer::capacity, buffer::data, buffer::len, buffer::offset, and secure_memzero().
Referenced by command_line_add(), command_line_next(), command_line_reset(), do_close_free_key_schedule(), key_method_2_read(), openvpn_PRF(), read_control_auth(), read_inline_file(), read_key_file(), read_pem_key_file(), tls_crypt_fail_msg_too_long(), tls_crypt_fail_replay(), tls_crypt_ignore_replay(), tls_crypt_loopback_max_len(), tls_crypt_loopback_zero_len(), tls_crypt_v2_unwrap_client_key(), tls_crypt_v2_write_client_key_file(), write_key_file(), and write_pem_key_file().
void buf_null_terminate | ( | struct buffer * | buf | ) |
Definition at line 569 of file buffer.c.
References BLAST, buf_inc_len(), buf_safe(), and buf_write_u8().
Referenced by buf_chomp(), buffer_read_from_file(), check_incoming_control_channel(), mutate_ncp_cipher_list(), secure_memzero(), and status_read().
bool buf_parse | ( | struct buffer * | buf, |
const int | delim, | ||
char * | line, | ||
const int | size | ||
) |
Definition at line 861 of file buffer.c.
References ASSERT, and buf_read_u8().
Referenced by apply_push_options(), get_auth_challenge(), get_user_pass_cr(), ifconfig_pool_read(), in_src_get(), make_inline_array(), man_kill(), man_output_peer_info_env(), options_warning_extract_parm1(), options_warning_safe_scan1(), options_warning_safe_scan2(), output_peer_info_env(), parse_auth_pending_keywords(), push_update_digest(), read_config_string(), and secure_memzero().
bool buf_printf | ( | struct buffer * | buf, |
const char * | format, | ||
... | |||
) |
Definition at line 242 of file buffer.c.
References BEND, buf_defined(), buf_forward_capacity(), buffer::capacity, buffer::data, buffer::len, and vsnprintf.
Referenced by add_option(), ce_management_query_proxy(), ce_management_query_remote(), check_inline_file(), construct_name_value(), foreign_option(), fork_dhcp_action(), fork_register_dns_action(), format_common_name(), format_hex_ex(), format_ip_addr_string(), format_route_entry(), frame_print(), get_device_guid(), get_unspecified_device_guid(), get_user_pass_cr(), hostname_randomize(), ifconfig_options_string(), ipset2ascii_all(), link_socket_connection_initiated(), log_entry_print(), management_callback_send_cc_message(), management_hold(), management_query_multiline(), management_query_user_pass(), mroute_addr_print_ex(), mroute_helper_regenerate(), msg_flags_string(), multi_instance_string(), ntlm_phase_1(), open_null(), options_string(), options_string_compat_lzo(), options_warning_safe_ml(), p2p_mode_ncp(), packet_id_net_print(), packet_id_persist_print(), platform_gen_path(), plugin_mask_string(), prepend_dir(), print_argv(), print_default_gateway(), print_in6_addr(), print_in_addr_t(), print_key_id(), print_link_socket_actual_ex(), print_netmask(), print_opt_route(), print_opt_route_gateway(), print_opt_route_gateway_dhcp(), print_opt_topology(), print_sockaddr_ex(), print_str(), print_str_int(), proto2ascii_all(), protocol_dump(), push_peer_info(), read_inline_file(), reliable_ack_print(), reliable_print_ids(), route_string(), secure_memzero(), send_auth_failed(), send_auth_pending_messages(), send_push_options(), send_push_reply(), send_push_reply_auth_token(), server_pushed_info(), setenv_format_indexed_name(), setenv_route(), setenv_route_addr(), setenv_route_ipv6(), setenv_str_safe(), socket_stat(), strerror_win32(), system_error_message(), time_string(), translate_mtu_discover_type_name(), tun_stat(), tv_string(), username_password_as_base64(), verify_cert(), wide_cmd_line(), win32_version_string(), window_title_generate(), and write_key_file().
bool buf_puts | ( | struct buffer * | buf, |
const char * | str | ||
) |
Definition at line 269 of file buffer.c.
References BEND, buf_forward_capacity(), buffer::capacity, buffer::data, buffer::len, and strncpynt().
Referenced by mutate_ncp_cipher_list(), print_sockaddr_ex(), and secure_memzero().
void buf_rmtail | ( | struct buffer * | buf, |
uint8_t | remove | ||
) |
Definition at line 554 of file buffer.c.
References BLAST, and buffer::len.
Referenced by secure_memzero(), and translate_mtu_discover_type_name().
void buf_size_error | ( | const size_t | size | ) |
Definition at line 55 of file buffer.c.
Referenced by alloc_buf(), alloc_buf_gc(), buf_set_read(), and buf_set_write().
bool buf_string_compare_advance | ( | struct buffer * | src, |
const char * | match | ||
) |
Definition at line 825 of file buffer.c.
References buf_advance(), and buf_string_match_head_str().
Referenced by buf_string_match_head(), process_incoming_push_msg(), and receive_auth_failed().
bool buf_string_match_head_str | ( | const struct buffer * | src, |
const char * | match | ||
) |
Definition at line 814 of file buffer.c.
References BPTR, and buffer::len.
Referenced by buf_string_compare_advance(), buf_string_match_head(), check_incoming_control_channel(), and receive_auth_failed().
Definition at line 223 of file buffer.c.
References buf_prepend(), buf_write_alloc(), buffer::capacity, CLEAR, and buffer::data.
Referenced by reliable_ack_write(), and socks_process_outgoing_udp().
int buf_substring_len | ( | const struct buffer * | buf, |
int | delim | ||
) |
Definition at line 839 of file buffer.c.
References buf_read_u8().
Referenced by buf_string_match_head(), and command_line_get().
void buffer_list_advance | ( | struct buffer_list * | ol, |
int | n | ||
) |
Definition at line 1361 of file buffer.c.
References ASSERT, BLEN, buffer_entry::buf, buf_advance(), buffer_list_pop(), and buffer_list::head.
Referenced by init_static(), and man_write().
void buffer_list_aggregate | ( | struct buffer_list * | bl, |
const size_t | max | ||
) |
Aggregates as many buffers as possible from bl
in a new buffer of maximum length max_len
.
All the aggregated buffers are removed from the list and replaced by the new one, followed by any additional (non-aggregated) data.
bl | the list of buffer to aggregate |
max | the maximum length of the aggregated buffer |
Definition at line 1338 of file buffer.c.
References buffer_list_aggregate_separator().
Referenced by init_static(), man_write(), and management_query_multiline_flatten().
void buffer_list_aggregate_separator | ( | struct buffer_list * | bl, |
const size_t | max_len, | ||
const char * | sep | ||
) |
Aggregates as many buffers as possible from bl
in a new buffer of maximum length max_len
.
sep
is written after each copied buffer (also after the last one). All the aggregated buffers are removed from the list and replaced by the new one, followed by any additional (non-aggregated) data. Nothing happens if max_len
is not enough to aggregate at least 2 buffers.
bl | the list of buffer to aggregate |
max_len | the maximum length of the aggregated buffer |
sep | the separator to put between buffers during aggregation |
Definition at line 1292 of file buffer.c.
References alloc_buf(), ALLOC_OBJ_CLEAR, BLEN, buffer_entry::buf, buf_copy(), buf_write(), http-client::f, free, free_buf(), buffer_list::head, buffer_entry::next, buffer_list::size, and buffer_list::tail.
Referenced by buffer_list_aggregate(), management_query_multiline_flatten_newline(), test_buffer_list_aggregate_separator_all(), test_buffer_list_aggregate_separator_empty(), test_buffer_list_aggregate_separator_emptybuffers(), test_buffer_list_aggregate_separator_noop(), test_buffer_list_aggregate_separator_nosep(), test_buffer_list_aggregate_separator_two(), and test_buffer_list_aggregate_separator_zerolen().
bool buffer_list_defined | ( | const struct buffer_list * | ol | ) |
Checks if the list is valid and non-empty.
ol | the list to check |
ol
is not NULL and contains at least one buffer Definition at line 1217 of file buffer.c.
References buffer_list::head.
Referenced by man_update_io_state(), management_query_multiline_flatten(), and management_query_multiline_flatten_newline().
struct buffer_list* buffer_list_file | ( | const char * | fn, |
int | max_line_len | ||
) |
Definition at line 1375 of file buffer.c.
References buffer_list_new(), buffer_list_push(), free, malloc, and platform_fopen().
Referenced by key_state_check_auth_pending_file().
void buffer_list_free | ( | struct buffer_list * | ol | ) |
Frees a buffer list and all the buffers in it.
ol | the list to free |
Definition at line 1207 of file buffer.c.
References buffer_list_reset(), and free.
Referenced by in_extra_dispatch(), in_extra_reset(), init_static(), key_state_check_auth_pending_file(), key_state_free(), man_connection_close(), management_client_auth(), management_query_multiline_flatten(), management_query_multiline_flatten_newline(), set_cc_config(), and test_buffer_list_teardown().
struct buffer_list* buffer_list_new | ( | const int | max_size | ) |
Allocate an empty buffer list of capacity max_size
.
max_size | the capacity of the list to allocate |
Definition at line 1197 of file buffer.c.
References ALLOC_OBJ_CLEAR, buffer_list::max_size, and buffer_list::size.
Referenced by buffer_list_file(), in_extra_reset(), init_static(), man_connection_init(), test_buffer_list_setup(), and tls_send_payload().
struct buffer* buffer_list_peek | ( | struct buffer_list * | ol | ) |
Retrieve the head buffer.
ol | the list to retrieve the buffer from |
Definition at line 1279 of file buffer.c.
References buffer_entry::buf, and buffer_list::head.
Referenced by flush_payload_buffer(), init_static(), man_write(), management_query_multiline_flatten(), management_query_multiline_flatten_newline(), test_buffer_list_aggregate_separator_all(), test_buffer_list_aggregate_separator_emptybuffers(), test_buffer_list_aggregate_separator_noop(), test_buffer_list_aggregate_separator_nosep(), test_buffer_list_aggregate_separator_two(), and test_buffer_list_aggregate_separator_zerolen().
void buffer_list_pop | ( | struct buffer_list * | ol | ) |
Definition at line 1344 of file buffer.c.
References buffer_entry::buf, free, free_buf(), buffer_list::head, buffer_entry::next, buffer_list::size, and buffer_list::tail.
Referenced by buffer_list_advance(), and flush_payload_buffer().
void buffer_list_push | ( | struct buffer_list * | ol, |
const char * | str | ||
) |
Allocates and appends a new buffer containing str
as data to ol
.
ol | the list to append the new buffer to |
str | the string to copy into the new buffer |
Definition at line 1238 of file buffer.c.
References buffer_entry::buf, buffer_list_push_data(), and buffer::len.
Referenced by buffer_list_file(), init_static(), man_output_list_push_str(), man_read(), test_buffer_list_full(), and test_buffer_list_setup().
struct buffer_entry* buffer_list_push_data | ( | struct buffer_list * | ol, |
const void * | data, | ||
size_t | size | ||
) |
Allocates and appends a new buffer containing data
of length size
.
ol | the list to append the new buffer to |
data | the data to copy into the new buffer |
size | the length of data to copy into the buffer |
Definition at line 1252 of file buffer.c.
References alloc_buf(), ALLOC_OBJ_CLEAR, ASSERT, buffer_entry::buf, buffer::data, buffer_list::head, buffer::len, buffer_list::max_size, buffer_entry::next, buffer_list::size, and buffer_list::tail.
Referenced by buffer_list_push(), test_buffer_list_setup(), and tls_send_payload().
void buffer_list_reset | ( | struct buffer_list * | ol | ) |
Empty the list ol
and frees all the contained buffers.
ol | the list to reset |
Definition at line 1223 of file buffer.c.
References buffer_entry::buf, free, free_buf(), buffer_list::head, buffer_entry::next, buffer_list::size, and buffer_list::tail.
Referenced by buffer_list_free(), man_new_connection_post(), man_read(), and man_reset_client_socket().
buffer_read_from_file - copy the content of a file into a buffer
file | path to the file to read |
gc | the garbage collector to use when allocating the buffer. It is passed to alloc_buf_gc() and therefore can be NULL. |
Definition at line 1398 of file buffer.c.
References alloc_buf_gc(), ASSERT, BPTR, buf_inc_len(), buf_null_terminate(), free_buf_gc(), platform_fopen(), and platform_stat().
Referenced by connection_entry_preload_key(), read_key_file(), and read_pem_key_file().
bool buffer_write_file | ( | const char * | filename, |
const struct buffer * | buf | ||
) |
Write buffer contents to file.
filename | The filename to write the buffer to. |
buf | The buffer to write to the file. |
Definition at line 369 of file buffer.c.
References BLEN, BPTR, M_ERRNO, msg, platform_open(), S_IRUSR, S_IWUSR, and write.
Referenced by secure_memzero(), tls_crypt_v2_verify_metadata(), tls_crypt_v2_write_client_key_file(), write_key_file(), and write_pem_key_file().
bool char_class | ( | const unsigned char | c, |
const unsigned int | flags | ||
) |
Definition at line 913 of file buffer.c.
References CC_ALNUM, CC_ALPHA, CC_ANY, CC_ASCII, CC_ASTERISK, CC_AT, CC_BACKSLASH, CC_BLANK, CC_CNTRL, CC_COLON, CC_COMMA, CC_CR, CC_DASH, CC_DIGIT, CC_DOT, CC_DOUBLE_QUOTE, CC_EQUAL, CC_GREATER_THAN, CC_LESS_THAN, CC_NEWLINE, CC_NULL, CC_PIPE, CC_PRINT, CC_PUNCT, CC_QUESTION_MARK, CC_REVERSE_QUOTE, CC_SINGLE_QUOTE, CC_SLASH, CC_SPACE, CC_UNDERBAR, and CC_XDIGIT.
Referenced by buf_chomp(), char_inc_exc(), and command_line_add().
|
inlinestatic |
Definition at line 1052 of file buffer.c.
References char_class().
Referenced by string_class(), and string_mod().
void chomp | ( | char * | str | ) |
Definition at line 650 of file buffer.c.
References rm_trailing_chars().
Referenced by establish_http_proxy_passthru(), get_console_input(), get_console_input_win32(), get_proxy_authenticate(), get_user_pass_cr(), get_user_pass_http(), make_inline_array(), man_output_peer_info_env(), output_peer_info_env(), secure_memzero(), and status_printf().
Definition at line 117 of file buffer.c.
References BLEN, BPTR, buf_debug_file, buf_debug_line, buf_init_dowork(), buffer::capacity, check_malloc_return(), buffer::data, buffer::len, malloc, and buffer::offset.
Referenced by mbuf_alloc_buf(), and tls_pre_decrypt_lite().
void convert_to_one_line | ( | struct buffer * | buf | ) |
Definition at line 354 of file buffer.c.
References BLEN, BPTR, and buffer::len.
Referenced by secure_memzero().
char* format_hex_ex | ( | const uint8_t * | data, |
int | size, | ||
int | maxoutput, | ||
unsigned int | space_break_flags, | ||
const char * | separator, | ||
struct gc_arena * | gc | ||
) |
Definition at line 519 of file buffer.c.
References alloc_buf_gc(), buf_catrunc(), buf_printf(), buffer::data, FHE_CAPS, FHE_SPACE_BREAK_MASK, and static_assert.
Referenced by backend_x509_get_serial_hex(), backend_x509_get_username(), export_user_keying_material(), format_hex(), hostname_randomize(), mroute_addr_print_ex(), print_default_gateway(), push_peer_info(), read_key_file(), show_adapter(), show_settings(), verify_cert(), verify_cert_set_env(), write_key_file(), and x509_setenv_track().
void free_buf | ( | struct buffer * | buf | ) |
Definition at line 185 of file buffer.c.
References CLEAR, buffer::data, and free.
Referenced by auth_token_init_secret(), buffer_list_aggregate_separator(), buffer_list_pop(), buffer_list_reset(), check_inline_file(), command_line_free(), do_close_free_key_schedule(), fragment_free(), fragment_list_buf_free(), free_context_buffers(), key_state_free(), link_socket_close(), management_query_cert(), management_query_pk_sig(), mbuf_free_buf(), mutate_ncp_cipher_list(), openvpn_PRF(), overlapped_io_close(), read_inline_file(), reliable_free(), send_line_crlf(), status_close(), stream_buf_close(), test_tls_crypt_teardown(), tls_crypt_v2_write_client_key_file(), tls_pre_decrypt_lite(), tls_wrap_free(), tun_show_debug(), and tuntap_dhcp_mask().
Definition at line 192 of file buffer.c.
References CLEAR, buffer::data, free, gc_arena::list, and gc_entry::next.
Referenced by buffer_read_from_file(), test_buffer_free_gc_one(), and test_buffer_free_gc_two().
void gc_addspecial | ( | void * | addr, |
void(*)(void *) | free_function, | ||
struct gc_arena * | a | ||
) |
Definition at line 474 of file buffer.c.
References gc_entry_special::addr, ASSERT, check_malloc_return(), gc_entry_special::free_fnc, gc_arena::list_special, malloc, and gc_entry_special::next.
Referenced by do_preresolve_host(), and init_route_list().
void* gc_malloc | ( | size_t | size, |
bool | clear, | ||
struct gc_arena * | a | ||
) |
Definition at line 405 of file buffer.c.
References check_malloc_return(), gc_arena::list, malloc, and gc_entry::next.
Referenced by add_route_ipv6(), alloc_buf_gc(), append_cipher_to_ncp_list(), argv_prep_format(), argv_printf_arglist(), delete_route_ipv6(), establish_http_proxy_passthru(), export_user_keying_material(), get_adapter_info_list(), get_auth_challenge(), get_interface_info_list(), get_ipv6_addr_no_netbits(), get_panel_reg(), get_per_adapter_info(), get_user_pass_cr(), get_windows_routing_table(), options_string_extract_option(), options_warning_extract_parm1(), options_warning_safe_scan1(), options_warning_safe_scan2(), parse_line(), plugin_vlog(), sanitize_control_message(), setenv_str_incr(), show_routes(), ssl_tls1_PRF(), string_alloc(), string_substitute(), tls_ctx_use_external_rsa_key(), translate_mtu_discover_type_name(), wide_cmd_line(), wide_string(), x509_get_subject(), and x_msg_va().
Definition at line 496 of file buffer.c.
References gc_arena::list, and gc_entry::next.
Referenced by add_option().
const char* np | ( | const char * | str | ) |
Definition at line 896 of file buffer.c.
Referenced by buf_string_match_head().
bool openvpn_snprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
... | |||
) |
Definition at line 296 of file buffer.c.
References buffer::len, and vsnprintf.
Referenced by add_proxy_headers(), add_route(), add_route_ipv6(), append_cipher_to_ncp_list(), backend_x509_get_username(), do_ifconfig_ipv4(), do_ifconfig_ipv6(), do_setenv_x509(), env_block(), establish_http_proxy_passthru(), get_panel_reg(), get_tap_reg(), ifconfig_pool_write(), init_key_ctx_bi(), key_state_check_auth_pending_file(), man_bytecount_output_client(), man_bytecount_output_server(), open_null(), openvpn_run_script(), platform_create_temp_file(), plugin_init_item(), plugin_vlog(), print_cert_details(), print_details(), secure_memzero(), set_user_script(), setenv_counter(), setenv_int(), setenv_long_long(), setenv_sockaddr(), setenv_str_incr(), socks_username_password_auth(), tap_allow_nonadmin_access(), tls_crypt_v2_verify_metadata(), tls_ctx_load_extra_certs(), tun_try_open_device(), verify_cert_set_env(), verify_check_crl_dir(), x509_setenv(), and x_msg_va().
bool openvpn_swprintf | ( | wchar_t *const | str, |
const size_t | size, | ||
const wchar_t *const | format, | ||
... | |||
) |
Definition at line 318 of file buffer.c.
References buffer::len.
Referenced by CheckConfigPath(), CreateClientPipeInstance(), get_adapter_index_method_1(), HandleEnableDHCPMessage(), netsh_dns_cmd(), RegisterDNS(), ReturnProcessId(), RunOpenvpn(), secure_memzero(), ValidateOptions(), and wmic_nicconfig_cmd().
char* print_argv | ( | const char ** | p, |
struct gc_arena * | gc, | ||
const unsigned int | flags | ||
) |
Definition at line 753 of file buffer.c.
References alloc_buf_gc(), BSTR, buf_printf(), and PA_BRACKET.
Referenced by argv_str(), plugin_open_item(), plugin_option_list_print(), and push_options().
void rm_trailing_chars | ( | char * | str, |
const char * | what_to_delete | ||
) |
Definition at line 659 of file buffer.c.
References buffer::len.
Referenced by chomp(), and secure_memzero().
const char* skip_leading_whitespace | ( | const char * | str | ) |
Definition at line 615 of file buffer.c.
Referenced by make_inline_array(), and secure_memzero().
char* string_alloc | ( | const char * | str, |
struct gc_arena * | gc | ||
) |
Definition at line 685 of file buffer.c.
References check_malloc_return(), and gc_malloc().
Referenced by add_env_item(), argv_clone(), argv_insert_head(), argv_parse_cmd(), auth_set_client_reason(), backend_x509_get_serial(), ccs_gen_config_file(), ccs_gen_deferred_ret_file(), check_file_access(), check_inline_file(), cipher_kt_block_size(), clone_push_list(), do_close_tun(), do_init_route_ipv6_list(), extract_var_peer_info(), fork_to_self(), generate_auth_token(), get_auth_challenge(), get_device_instance_id_interface(), get_ipv6_addr_no_netbits(), get_p2p_ncp_cipher(), get_pa_var(), get_panel_reg(), get_proxy_authenticate(), get_tap_reg(), hash_iterator_delete_element(), ifconfig_pool_acquire(), ifconfig_pool_set(), init_options_dev(), key_method_2_read(), key_state_gen_auth_control_files(), log_history_add(), make_arg_array(), make_base64_string2(), make_inline_array(), man_settings_init(), management_callback_proxy_cmd(), ms_error_text(), mutate_ncp_cipher_list(), ncp_get_best_cipher(), open_null(), open_syslog(), options_warning_extract_parm1(), parse_hash_fingerprint_multiline(), parse_http_proxy_override(), push_option_fmt(), read_inline_file(), RSA_meth_new(), set_common_name(), set_win_sys_path(), ssl_put_auth_challenge(), status_open(), string_alloc_buf(), string_mod_const(), test_cipher_names(), tls_ctx_set_tls_groups(), tls_item_in_cipher_list(), tls_lock_common_name(), tls_lock_username(), tls_poor_mans_ncp(), and tun_open_device().
Definition at line 788 of file buffer.c.
References ASSERT, buf_set_read(), buffer::len, and string_alloc().
Referenced by options_warning_extract_parm1().
int string_array_len | ( | const char ** | array | ) |
Definition at line 739 of file buffer.c.
Referenced by make_arg_copy(), make_extended_arg_array(), no_more_than_n_args(), and openvpn_plugin_open_v3().
bool string_class | ( | const char * | str, |
const unsigned int | inclusive, | ||
const unsigned int | exclusive | ||
) |
Definition at line 1058 of file buffer.c.
References ASSERT, and char_inc_exc().
Referenced by dns_addr_safe(), openvpn_inet_aton(), push_option_ex(), and wide_cmd_line().
void string_clear | ( | char * | str | ) |
Definition at line 727 of file buffer.c.
References secure_memzero().
Referenced by do_init_crypto_tls_c1(), get_user_pass_cr(), and openvpn_plugin_string_list_item_free().
bool string_mod | ( | char * | str, |
const unsigned int | inclusive, | ||
const unsigned int | exclusive, | ||
const char | replace | ||
) |
Definition at line 1077 of file buffer.c.
References ASSERT, and char_inc_exc().
Referenced by check_incoming_control_channel(), do_setenv_x509(), get_user_pass_cr(), string_mod_const(), string_mod_remap_name(), string_replace_leading(), verify_user_pass(), wide_cmd_line(), and x509_setenv().
const char* string_mod_const | ( | const char * | str, |
const unsigned int | inclusive, | ||
const unsigned int | exclusive, | ||
const char | replace, | ||
struct gc_arena * | gc | ||
) |
Definition at line 1109 of file buffer.c.
References string_alloc(), and string_mod().
Referenced by platform_gen_path(), safe_print(), and setenv_str_ex().
void string_null_terminate | ( | char * | str, |
int | len, | ||
int | capacity | ||
) |
Definition at line 633 of file buffer.c.
References ASSERT, and buffer::len.
Referenced by get_console_input_win32(), and secure_memzero().
void string_replace_leading | ( | char * | str, |
const char | match, | ||
const char | replace | ||
) |
Definition at line 1128 of file buffer.c.
References ASSERT, BPTR, buf_debug_file, buf_debug_line, buffer::capacity, D_ALIGN_DEBUG, D_ALIGN_ERRORS, buffer::data, buffer::len, msg, buffer::offset, PAYLOAD_ALIGN, ptr_format, and string_mod().
Referenced by verify_cert().
void x_gc_free | ( | struct gc_arena * | a | ) |
Definition at line 439 of file buffer.c.
References free, gc_arena::list, and gc_entry::next.
Referenced by gc_free().
void x_gc_freespecial | ( | struct gc_arena * | a | ) |
Definition at line 458 of file buffer.c.
References gc_entry_special::addr, free, gc_entry_special::free_fnc, gc_arena::list_special, and gc_entry_special::next.
Referenced by gc_free().