monitor: Fix invalid access
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 8 Mar 2021 22:08:16 +0000 (14:08 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
ident can be NULL when printing user logs which may lead ot invalid
access.

Fixes: https://github.com/bluez/bluez/issues/92
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
monitor/packet.c

index ff35db0..9106c03 100755 (executable)
@@ -11312,7 +11312,7 @@ void packet_user_logging(struct timeval *tv, struct ucred *cred,
                        label = "Message";
        }
 
-       if (ident[0] == '<' || ident[0] == '>') {
+       if (ident && (ident[0] == '<' || ident[0] == '>')) {
                packet_decode(tv, cred, ident[0], index, color,
                                label == ident ? &ident[2] : label,
                                data, size);