From 59588089e7292abaa537d9d6da9b537e4caf942f Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 16 May 2020 17:50:52 +0200 Subject: [PATCH] device_manager: missing NULL checks. We should investigate why there are anonymous or unset attributes. But at least let's not KDL because of it. Fixes #16038. Change-Id: Ifd49475e25ce8dcc3e98bc22df81f0e4f493f915 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2710 Reviewed-by: waddlesplash --- src/system/kernel/device_manager/device_manager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/device_manager/device_manager.cpp b/src/system/kernel/device_manager/device_manager.cpp index bc6600c8e7..2f3713221b 100644 --- a/src/system/kernel/device_manager/device_manager.cpp +++ b/src/system/kernel/device_manager/device_manager.cpp @@ -529,7 +529,10 @@ control_device_manager(const char* subsystem, uint32 function, void* buffer, device_attr* attr = iterator.Next(); attrInfo.cookie = (device_node_cookie)attr; - strlcpy(attrInfo.name, attr->name, 254); + if (attr->name != NULL) + strlcpy(attrInfo.name, attr->name, 254); + else + attrInfo.name[0] = '\0'; attrInfo.type = attr->type; switch (attrInfo.type) { case B_UINT8_TYPE: @@ -545,7 +548,10 @@ control_device_manager(const char* subsystem, uint32 function, void* buffer, attrInfo.value.ui64 = attr->value.ui64; break; case B_STRING_TYPE: - strlcpy(attrInfo.value.string, attr->value.string, 254); + if (attr->value.string != NULL) + strlcpy(attrInfo.value.string, attr->value.string, 254); + else + attrInfo.value.string[0] = '\0'; break; /*case B_RAW_TYPE: if (attr.value.raw.length > attr_info->attr.value.raw.length)