[openssl] master update
Dr. Paul Dale
pauli at openssl.org
Mon Aug 12 21:39:56 UTC 2019
The branch master has been updated
via 697b0c5185f2b379cf23330fddc5f8b2d691db17 (commit)
from 5acb2be58b693f504c76eb07f5b9133b02895f3b (commit)
- Log -----------------------------------------------------------------
commit 697b0c5185f2b379cf23330fddc5f8b2d691db17
Author: Rich Salz <rsalz at akamai.com>
Date: Mon Aug 12 13:23:17 2019 +1000
Fix doc example code to follow coding style
Reviewed-by: Paul Dale <paul.dale at oracle.com>
Reviewed-by: Matt Caswell <matt at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9577)
-----------------------------------------------------------------------
Summary of changes:
doc/man3/OSSL_PARAM_construct_from_text.pod | 48 +++++++++++++++--------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/doc/man3/OSSL_PARAM_construct_from_text.pod b/doc/man3/OSSL_PARAM_construct_from_text.pod
index 28d5e6fc13..e8e2639864 100644
--- a/doc/man3/OSSL_PARAM_construct_from_text.pod
+++ b/doc/man3/OSSL_PARAM_construct_from_text.pod
@@ -89,14 +89,13 @@ Code that looked like this:
{
int rv;
char *stmp, *vtmp = NULL;
+
stmp = OPENSSL_strdup(value);
- if (!stmp)
+ if (stmp == NULL)
return -1;
vtmp = strchr(stmp, ':');
- if (vtmp) {
- *vtmp = 0;
- vtmp++;
- }
+ if (vtmp != NULL)
+ *vtmp++ = '\0';
rv = EVP_MAC_ctrl_str(ctx, stmp, vtmp);
OPENSSL_free(stmp);
return rv;
@@ -105,9 +104,9 @@ Code that looked like this:
...
- char *macopt;
for (i = 0; i < sk_OPENSSL_STRING_num(macopts); i++) {
- macopt = sk_OPENSSL_STRING_value(macopts, i);
+ char *macopt = sk_OPENSSL_STRING_value(macopts, i);
+
if (pkey_ctrl_string(mac_ctx, macopt) <= 0) {
BIO_printf(bio_err,
"MAC parameter error \"%s\"\n", macopt);
@@ -119,37 +118,40 @@ Code that looked like this:
Can be written like this instead:
OSSL_PARAM *params =
- OPENSSL_zalloc(sizeof(OSSL_PARAM)
+ OPENSSL_zalloc(sizeof(*params)
* (sk_OPENSSL_STRING_num(opts) + 1));
const OSSL_PARAM *paramdefs = EVP_MAC_CTX_set_param_types(mac);
size_t params_n;
+ char *opt = "<unknown>";
for (params_n = 0; params_n < (size_t)sk_OPENSSL_STRING_num(opts);
params_n++) {
- char *opt = sk_OPENSSL_STRING_value(opts, (int)params_n);
char *stmp, *vtmp = NULL;
+ opt = sk_OPENSSL_STRING_value(opts, (int)params_n);
if ((stmp = OPENSSL_strdup(opt)) == NULL
- || (vtmp = strchr(stmp, ':')) == NULL
- || (*vtmp++ = '\0') /* Always zero */
- || !OSSL_PARAM_allocate_from_text(¶ms[params_n],
- paramdefs,
- stmp, vtmp, strlen(vtmp))) {
- BIO_printf(bio_err, "MAC parameter error '%s'\n", opt);
- ERR_print_errors(bio_err);
+ || (vtmp = strchr(stmp, ':')) == NULL)
+ goto err;
+
+ *vtmp++ = '\0';
+ if (!OSSL_PARAM_allocate_from_text(¶ms[params_n],
+ paramdefs, stmp,
+ vtmp, strlen(vtmp)))
goto err;
- }
}
params[params_n] = OSSL_PARAM_construct_end();
- if (!EVP_MAC_CTX_set_params(ctx, params)) {
- BIO_printf(bio_err, "MAC parameter error\n");
- ERR_print_errors(bio_err);
+ if (!EVP_MAC_CTX_set_params(ctx, params))
goto err;
- }
- for (; params_n-- > 0;) {
+ while (params_n-- > 0)
OPENSSL_free(params[params_n].data);
- }
OPENSSL_free(params);
+ /* ... */
+ return;
+
+ err:
+ BIO_printf(bio_err, "MAC parameter error '%s'\n", opt);
+ ERR_print_errors(bio_err);
+
=head1 SEE ALSO
More information about the openssl-commits
mailing list