From e4416ac75272d1fb9194ec845c00d2af036e02ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Tue, 23 Feb 2021 13:56:19 +0100 Subject: [PATCH] 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 bde8ff3b4..dfe8d18e3 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)); + } } }