diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/openssl/buffer.h | 35 | ||||
-rw-r--r-- | include/openssl/crypto.h | 22 |
2 files changed, 31 insertions, 26 deletions
diff --git a/include/openssl/buffer.h b/include/openssl/buffer.h index f22ed09713..47d68f81c3 100644 --- a/include/openssl/buffer.h +++ b/include/openssl/buffer.h @@ -60,6 +60,10 @@ # define HEADER_BUFFER_H # include <openssl/ossl_typ.h> +# ifndef HEADER_CRYPTO_H +# include <openssl/crypto.h> +# endif + #ifdef __cplusplus extern "C" { @@ -71,9 +75,17 @@ extern "C" { # include <sys/types.h> # endif -/* Already declared in ossl_typ.h */ -/* typedef struct buf_mem_st BUF_MEM; */ - +/* + * These names are outdated as of OpenSSL 1.1; a future release + * will move them to be deprecated. + */ +# define BUF_strdup(s) OPENSSL_strdup(s) +# define BUF_strndup(s, size) OPENSSL_strndup(s, size) +# define BUF_memdup(data, size) OPENSSL_memdup(data, size) +# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) +# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) +# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) + struct buf_mem_st { size_t length; /* current number of bytes */ char *data; @@ -88,22 +100,8 @@ BUF_MEM *BUF_MEM_new_ex(unsigned long flags); void BUF_MEM_free(BUF_MEM *a); size_t BUF_MEM_grow(BUF_MEM *str, size_t len); size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); -size_t BUF_strnlen(const char *str, size_t maxlen); -char *BUF_strdup(const char *str); - -/* - * Like strndup, but in addition, explicitly guarantees to never read past the - * first |siz| bytes of |str|. - */ -char *BUF_strndup(const char *str, size_t siz); - -void *BUF_memdup(const void *data, size_t siz); void BUF_reverse(unsigned char *out, unsigned char *in, size_t siz); -/* safe string functions */ -size_t BUF_strlcpy(char *dst, const char *src, size_t siz); -size_t BUF_strlcat(char *dst, const char *src, size_t siz); - /* BEGIN ERROR CODES */ /* * The following lines are auto generated by the script mkerr.pl. Any changes @@ -114,12 +112,9 @@ void ERR_load_BUF_strings(void); /* Error codes for the BUF functions. */ /* Function codes. */ -# define BUF_F_BUF_MEMDUP 103 # define BUF_F_BUF_MEM_GROW 100 # define BUF_F_BUF_MEM_GROW_CLEAN 105 # define BUF_F_BUF_MEM_NEW 101 -# define BUF_F_BUF_STRDUP 102 -# define BUF_F_BUF_STRNDUP 104 /* Reason codes. */ diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 78d86b12f1..977481b57d 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -319,18 +319,25 @@ int CRYPTO_is_mem_check_on(void); # define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) # define is_MemCheck_on() CRYPTO_is_mem_check_on() -# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) -# define OPENSSL_zalloc(num) CRYPTO_zalloc((int)num,__FILE__,__LINE__) -# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__) +# define OPENSSL_malloc(num) CRYPTO_malloc((int)num, __FILE__, __LINE__) +# define OPENSSL_zalloc(num) CRYPTO_zalloc((int)num, __FILE__, __LINE__) +# define OPENSSL_memdup(str, s) CRYPTO_memdup((str), s, __FILE__, __LINE__) +# define OPENSSL_strdup(str) CRYPTO_strdup((str), __FILE__, __LINE__) +# define OPENSSL_strndup(str, s) CRYPTO_strndup((str), (s), __FILE__, __LINE__) # define OPENSSL_realloc(addr,num) \ - CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) + CRYPTO_realloc((char *)addr, (int)num, __FILE__, __LINE__) # define OPENSSL_realloc_clean(addr,old_num,num) \ - CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) + CRYPTO_realloc_clean(addr, old_num, num, __FILE__, __LINE__) # define OPENSSL_remalloc(addr,num) \ - CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) + CRYPTO_remalloc((char **)addr, (int)num, __FILE__, __LINE__) # define OPENSSL_clear_free(addr, num) CRYPTO_clear_free(addr, num) # define OPENSSL_free(addr) CRYPTO_free(addr) +size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); +size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); +size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); +size_t OPENSSL_strnlen(const char *str, size_t maxlen); + # define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type)) unsigned long OpenSSL_version_num(void); @@ -469,7 +476,9 @@ void CRYPTO_get_mem_debug_functions(void (**m) void *CRYPTO_malloc(int num, const char *file, int line); void *CRYPTO_zalloc(int num, const char *file, int line); +void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); char *CRYPTO_strdup(const char *str, const char *file, int line); +char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); void CRYPTO_free(void *ptr); void CRYPTO_clear_free(void *ptr, size_t num); void *CRYPTO_realloc(void *addr, int num, const char *file, int line); @@ -585,6 +594,7 @@ void ERR_load_CRYPTO_strings(void); # define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 # define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 # define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 +# define CRYPTO_F_CRYPTO_MEMDUP 115 # define CRYPTO_F_CRYPTO_NEW_EX_DATA 112 # define CRYPTO_F_CRYPTO_SET_EX_DATA 102 # define CRYPTO_F_DEF_ADD_INDEX 104 |