Welcome! Log In Create A New Profile

Advanced

[njs] Fixed unitialized value usage warning.

Dmitry Volyntsev
January 06, 2023 07:54PM
details: https://hg.nginx.org/njs/rev/1a5d22feadc2
branches:
changeset: 2023:1a5d22feadc2
user: Dmitry Volyntsev <xeioex@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");
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed unitialized value usage warning.

Dmitry Volyntsev 308 January 06, 2023 07:54PM



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

Online Users

Guests: 126
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