You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ko...@apache.org on 2021/03/04 06:12:31 UTC

[mynewt-nimble] 03/03: mesh: fix possible NULL dereference in bt_test_print_credentials

This is an automated email from the ASF dual-hosted git repository.

kopyscinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit e4416ac75272d1fb9194ec845c00d2af036e02ca
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Tue Feb 23 13:56:19 2021 +0100

    mesh: fix possible NULL dereference in bt_test_print_credentials
---
 nimble/host/mesh/src/testing.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/nimble/host/mesh/src/testing.c b/nimble/host/mesh/src/testing.c
index bde8ff3..dfe8d18 100644
--- a/nimble/host/mesh/src/testing.c
+++ b/nimble/host/mesh/src/testing.c
@@ -170,12 +170,14 @@ void bt_test_print_credentials(void)
 
 		console_printf("Friend cred: %d\n", i);
 		console_printf("\tNetKeyIdx: %04x\n",
-			           sub[i].net_idx);
-		console_printf("\tNID: %02x\n", subnet->keys->msg.nid);
-		console_printf("\tEncKey: %s\n",
-			       bt_hex(subnet->keys->msg.enc, 16));
-		console_printf("\tPrivKey: %s\n",
-			       bt_hex(subnet->keys->msg.privacy, 16));
+			       sub[i].net_idx);
+		if (subnet) {
+			console_printf("\tNID: %02x\n", subnet->keys->msg.nid);
+			console_printf("\tEncKey: %s\n",
+				       bt_hex(subnet->keys->msg.enc, 16));
+			console_printf("\tPrivKey: %s\n",
+				       bt_hex(subnet->keys->msg.privacy, 16));
+		}
 	}
 }