buffer(3) OpenSSL buffer(3) NNAAMMEE BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple char- acter array structure BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat - stan- dard C library equivalents SSYYNNOOPPSSIISS #include BUF_MEM *BUF_MEM_new(void); void BUF_MEM_free(BUF_MEM *a); int BUF_MEM_grow(BUF_MEM *str, int len); char *BUF_strdup(const char *str); char *BUF_strndup(const char *str, size_t siz); void *BUF_memdup(const void *data, size_t siz); size_t BUF_strlcpy(char *dst, const char *src, size_t size); size_t BUF_strlcat(char *dst, const char *src, size_t size); size_t BUF_strnlen(const char *str, size_t maxlen); DDEESSCCRRIIPPTTIIOONN The buffer library handles simple character arrays. Buffers are used for various purposes in the library, most notably memory BIOs. _B_U_F___M_E_M___n_e_w_(_) allocates a new buffer of zero size. _B_U_F___M_E_M___f_r_e_e_(_) frees up an already existing buffer. The data is zeroed before freeing up in case the buffer contains sensitive data. _B_U_F___M_E_M___g_r_o_w_(_) changes the size of an already existing buffer to lleenn. Any data already in the buffer is preserved if it increases in size. _B_U_F___s_t_r_d_u_p_(_), _B_U_F___s_t_r_n_d_u_p_(_), _B_U_F___m_e_m_d_u_p_(_), _B_U_F___s_t_r_l_c_p_y_(_), _B_U_F___s_t_r_l_c_a_t_(_) and BUF_strnlen are equivalents of the standard C library functions. The _d_u_p_(_) functions use _O_P_E_N_S_S_L___m_a_l_l_o_c_(_) underneath and so should be used in preference to the standard library for memory leak checking or replacing the _m_a_l_l_o_c_(_) function. Memory allocated from these functions should be freed up using the _O_P_E_N_S_S_L___f_r_e_e_(_) function. BUF_strndup makes the explicit guarantee that it will never read past the first ssiizz bytes of ssttrr. RREETTUURRNN VVAALLUUEESS _B_U_F___M_E_M___n_e_w_(_) returns the buffer or NULL on error. _B_U_F___M_E_M___f_r_e_e_(_) has no return value. _B_U_F___M_E_M___g_r_o_w_(_) returns zero on error or the new size (i.e. lleenn). SSEEEE AALLSSOO _b_i_o(3) HHIISSTTOORRYY _B_U_F___M_E_M___n_e_w_(_), _B_U_F___M_E_M___f_r_e_e_(_) and _B_U_F___M_E_M___g_r_o_w_(_) are available in all versions of SSLeay and OpenSSL. _B_U_F___s_t_r_d_u_p_(_) was added in SSLeay 0.8. 1.0.2u 2019-12-20 buffer(3)