1buffer(3) OpenSSL buffer(3)
2
3
4
6 BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
7 character array structure
8
9 BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
10 standard C library equivalents
11
13 #include <openssl/buffer.h>
14
15 BUF_MEM *BUF_MEM_new(void);
16
17 void BUF_MEM_free(BUF_MEM *a);
18
19 int BUF_MEM_grow(BUF_MEM *str, int len);
20
21 char *BUF_strdup(const char *str);
22
23 char *BUF_strndup(const char *str, size_t siz);
24
25 void *BUF_memdup(const void *data, size_t siz);
26
27 size_t BUF_strlcpy(char *dst, const char *src, size_t size);
28
29 size_t BUF_strlcat(char *dst, const char *src, size_t size);
30
31 size_t BUF_strnlen(const char *str, size_t maxlen);
32
34 The buffer library handles simple character arrays. Buffers are used
35 for various purposes in the library, most notably memory BIOs.
36
37 BUF_MEM_new() allocates a new buffer of zero size.
38
39 BUF_MEM_free() frees up an already existing buffer. The data is zeroed
40 before freeing up in case the buffer contains sensitive data.
41
42 BUF_MEM_grow() changes the size of an already existing buffer to len.
43 Any data already in the buffer is preserved if it increases in size.
44
45 BUF_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy(), BUF_strlcat()
46 and BUF_strnlen are equivalents of the standard C library functions.
47 The dup() functions use OPENSSL_malloc() underneath and so should be
48 used in preference to the standard library for memory leak checking or
49 replacing the malloc() function.
50
51 Memory allocated from these functions should be freed up using the
52 OPENSSL_free() function.
53
54 BUF_strndup makes the explicit guarantee that it will never read past
55 the first siz bytes of str.
56
58 BUF_MEM_new() returns the buffer or NULL on error.
59
60 BUF_MEM_free() has no return value.
61
62 BUF_MEM_grow() returns zero on error or the new size (i.e. len).
63
65 bio(3)
66
68 BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all
69 versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8.
70
71
72
731.0.2o 2019-09-10 buffer(3)