[njs] Fixed unitialized value usage warning.
Dmitry Volyntsev
xeioex at nginx.com
Sat Jan 7 00:52:51 UTC 2023
details: https://hg.nginx.org/njs/rev/1a5d22feadc2
branches:
changeset: 2023:1a5d22feadc2
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Thu Jan 05 22:05:03 2023 -0800
description:
Fixed unitialized value usage warning.
Found by Coverity (CID 1518908).
diffstat:
external/njs_webcrypto_module.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (33 lines):
diff -r 2a412a132cf2 -r 1a5d22feadc2 external/njs_webcrypto_module.c
--- a/external/njs_webcrypto_module.c Wed Jan 04 20:39:21 2023 -0800
+++ b/external/njs_webcrypto_module.c Thu Jan 05 22:05:03 2023 -0800
@@ -3212,6 +3212,8 @@ njs_ext_import_key(njs_vm_t *vm, njs_val
njs_webcrypto_key_format_t fmt;
pkey = NULL;
+ key_data.start = NULL;
+ key_data.length = 0;
fmt = njs_key_format(vm, njs_arg(args, nargs, 1));
if (njs_slow_path(fmt == NJS_KEY_FORMAT_UNKNOWN)) {
@@ -3266,11 +3268,9 @@ njs_ext_import_key(njs_vm_t *vm, njs_val
* key->hash = NJS_HASH_UNSET;
*/
- start = key_data.start;
-
switch (fmt) {
case NJS_KEY_FORMAT_PKCS8:
- bio = njs_bio_new_mem_buf(start, key_data.length);
+ bio = njs_bio_new_mem_buf(key_data.start, key_data.length);
if (njs_slow_path(bio == NULL)) {
njs_webcrypto_error(vm, "BIO_new_mem_buf() failed");
goto fail;
@@ -3299,6 +3299,7 @@ njs_ext_import_key(njs_vm_t *vm, njs_val
break;
case NJS_KEY_FORMAT_SPKI:
+ start = key_data.start;
pkey = d2i_PUBKEY(NULL, &start, key_data.length);
if (njs_slow_path(pkey == NULL)) {
njs_webcrypto_error(vm, "d2i_PUBKEY() failed");
More information about the nginx-devel
mailing list