From: Inga Stotland Date: Fri, 8 Oct 2021 18:48:30 +0000 (-0700) Subject: tools/mesh-cfg-client: Fix NULL pointer dereferencing X-Git-Tag: submit/tizen/20220313.220938~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=668a7a3e75b94e52f6ad6ee08e1336ecdf3168b6;p=platform%2Fupstream%2Fbluez.git tools/mesh-cfg-client: Fix NULL pointer dereferencing This patch fixes a number of potential NULL pointer dereferencing cases. Signed-off-by: Ayush Garg --- diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 2bf1a15..f815c51 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -668,8 +668,6 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, break; } - bt_shell_printf("Period\t\t%d ms\n", pub.period); - pub.rtx_cnt = data[9] & 0x7; pub.rtx_interval = ((data[9] >> 3) + 1) * 50; bt_shell_printf("Rexmit count\t%d\n", pub.rtx_cnt); diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index 195029d..46e9ccf 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -2510,7 +2510,8 @@ void *mesh_db_prepare_export(void) jarray = json_object_new_array(); json_object_object_add(export, "scenes", jarray); - write_bool(export, "partial", false); + if (!write_bool(export, "partial", false)) + l_warn("Failed to write\"partial\" property"); return export; } diff --git a/tools/mesh/remote.c b/tools/mesh/remote.c index 054da53..6ec220a 100644 --- a/tools/mesh/remote.c +++ b/tools/mesh/remote.c @@ -281,6 +281,9 @@ bool remote_update_net_key(uint16_t addr, uint16_t net_idx, bool update, key = l_queue_find(rmt->net_keys, match_key, L_UINT_TO_PTR(net_idx)); + if (!key) + return false; + key->updated = update; if (save) @@ -343,6 +346,9 @@ bool remote_update_app_key(uint16_t addr, uint16_t app_idx, bool update, key = l_queue_find(rmt->app_keys, match_key, L_UINT_TO_PTR(app_idx)); + if (!key) + return false; + key->updated = update; if (save)