Welcome! Log In Create A New Profile

Advanced

[njs] WebCrypto: fixed dangling pointer warning by gcc-12.

Dmitry Volyntsev
September 06, 2022 01:38PM
details: https://hg.nginx.org/njs/rev/c597cd200724
branches:
changeset: 1947:c597cd200724
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Sep 06 10:09:08 2022 -0700
description:
WebCrypto: fixed dangling pointer warning by gcc-12.

diffstat:

external/njs_webcrypto_module.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)

diffs (82 lines):

diff -r 506ba9a639b8 -r c597cd200724 external/njs_webcrypto_module.c
--- a/external/njs_webcrypto_module.c Thu Sep 01 18:12:27 2022 -0700
+++ b/external/njs_webcrypto_module.c Tue Sep 06 10:09:08 2022 -0700
@@ -121,7 +121,7 @@ static njs_int_t njs_ext_get_random_valu

static void njs_webcrypto_cleanup_pkey(void *data);
static njs_webcrypto_key_format_t njs_key_format(njs_vm_t *vm,
- njs_value_t *value, njs_str_t *format);
+ njs_value_t *value);
static njs_int_t njs_key_usage(njs_vm_t *vm, njs_value_t *value,
unsigned *mask);
static njs_webcrypto_algorithm_t *njs_key_algorithm(njs_vm_t *vm,
@@ -1649,7 +1649,7 @@ njs_ext_import_key(njs_vm_t *vm, njs_val
unsigned usage;
EVP_PKEY *pkey;
njs_int_t ret;
- njs_str_t key_data, format;
+ njs_str_t key_data;
njs_value_t value, *options;
const u_char *start;
#if (OPENSSL_VERSION_NUMBER < 0x30000000L)
@@ -1669,9 +1669,8 @@ njs_ext_import_key(njs_vm_t *vm, njs_val

pkey = NULL;

- fmt = njs_key_format(vm, njs_arg(args, nargs, 1), &format);
+ fmt = njs_key_format(vm, njs_arg(args, nargs, 1));
if (njs_slow_path(fmt == NJS_KEY_FORMAT_UNKNOWN)) {
- njs_type_error(vm, "unknown key format: \"%V\"", &format);
goto fail;
}

@@ -1746,7 +1745,7 @@ njs_ext_import_key(njs_vm_t *vm, njs_val
break;

default:
- njs_internal_error(vm, "not implemented key format: \"%V\"", &format);
+ njs_internal_error(vm, "not implemented key format: \"jwk\"");
goto fail;
}

@@ -2484,9 +2483,10 @@ njs_webcrypto_cleanup_pkey(void *data)


static njs_webcrypto_key_format_t
-njs_key_format(njs_vm_t *vm, njs_value_t *value, njs_str_t *format)
+njs_key_format(njs_vm_t *vm, njs_value_t *value)
{
njs_int_t ret;
+ njs_str_t format;
njs_uint_t fmt;
njs_value_t string;

@@ -2502,21 +2502,25 @@ njs_key_format(njs_vm_t *vm, njs_value_t

ret = njs_value_to_string(vm, &string, value);
if (njs_slow_path(ret != NJS_OK)) {
- return NJS_ERROR;
+ goto fail;
}

- njs_string_get(&string, format);
+ njs_string_get(&string, &format);

fmt = 0;

while (fmt < sizeof(formats) / sizeof(formats[0])) {
- if (njs_strstr_eq(format, &formats[fmt].name)) {
+ if (njs_strstr_eq(&format, &formats[fmt].name)) {
return formats[fmt].value;
}

fmt++;
}

+fail:
+
+ njs_type_error(vm, "unknown key format: \"%V\"", &format);
+
return NJS_KEY_FORMAT_UNKNOWN;
}

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] WebCrypto: fixed dangling pointer warning by gcc-12.

Dmitry Volyntsev 143 September 06, 2022 01:38PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 114
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready