summaryrefslogtreecommitdiffstats
path: root/doc/man3/OSSL_PARAM_int.pod
diff options
context:
space:
mode:
Diffstat (limited to 'doc/man3/OSSL_PARAM_int.pod')
-rw-r--r--doc/man3/OSSL_PARAM_int.pod20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/man3/OSSL_PARAM_int.pod b/doc/man3/OSSL_PARAM_int.pod
index d637d94f8a..25b87014b7 100644
--- a/doc/man3/OSSL_PARAM_int.pod
+++ b/doc/man3/OSSL_PARAM_int.pod
@@ -184,8 +184,7 @@ size I<rsize> is created.
OSSL_PARAM_construct_utf8_string() is a function that constructs a UTF8
string OSSL_PARAM structure.
A parameter with name I<key>, storage I<buf> and size I<bsize> is created.
-If I<bsize> is zero, the string length is determined using strlen(3) + 1 for the
-null termination byte.
+If I<bsize> is zero, the string length is determined using strlen(3).
Generally pass zero for I<bsize> instead of calling strlen(3) yourself.
OSSL_PARAM_construct_octet_string() is a function that constructs an OCTET
@@ -232,15 +231,18 @@ will be assigned the size the parameter's I<data> buffer should have.
OSSL_PARAM_get_utf8_string() retrieves a UTF8 string from the parameter
pointed to by I<p>.
-The string is either stored into I<*val> with a length limit of I<max_len> or,
-in the case when I<*val> is NULL, memory is allocated for the string and
-I<max_len> is ignored.
+The string is stored into I<*val> with a size limit of I<max_len>,
+which must be large enough to accomodate a terminating NUL byte,
+otherwise this function will fail.
+If I<*val> is NULL, memory is allocated for the string and I<max_len>
+is ignored.
If memory is allocated by this function, it must be freed by the caller.
OSSL_PARAM_set_utf8_string() sets a UTF8 string from the parameter pointed to
by I<p> to the value referenced by I<val>.
If the parameter's I<data> field is NULL, then only its I<return_size> field
-will be assigned the size the parameter's I<data> buffer should have.
+will be assigned the minimum size the parameter's I<data> buffer should have
+to accomodate the string, including a terminating NUL byte.
OSSL_PARAM_get_octet_string() retrieves an OCTET string from the parameter
pointed to by I<p>.
@@ -334,11 +336,11 @@ This example is for setting parameters on some object:
#include <openssl/core.h>
const char *foo = "some string";
- size_t foo_l = strlen(foo) + 1;
+ size_t foo_l = strlen(foo);
const char bar[] = "some other string";
const OSSL_PARAM set[] = {
OSSL_PARAM_utf8_ptr("foo", &foo, foo_l),
- OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)),
+ OSSL_PARAM_utf8_string("bar", bar, sizeof(bar) - 1),
OSSL_PARAM_END
};
@@ -366,7 +368,7 @@ could fill in the parameters like this:
if ((p = OSSL_PARAM_locate(params, "foo")) != NULL)
OSSL_PARAM_set_utf8_ptr(p, "foo value");
if ((p = OSSL_PARAM_locate(params, "bar")) != NULL)
- OSSL_PARAM_set_utf8_ptr(p, "bar value");
+ OSSL_PARAM_set_utf8_string(p, "bar value");
if ((p = OSSL_PARAM_locate(params, "cookie")) != NULL)
OSSL_PARAM_set_utf8_ptr(p, "cookie value");