When following the code path for the extended message configurations, the code should run into a NULL-deref when using
DIAG_CMD_EXTENDED_MESSAGE_CONFIGURATION and DIAG_CMD_OP_SET_ALL_MSG_MASK with a non-zero mask.
Call path:
handle_extended_message_configuration()
peripheral_broadcast_msg_mask(range = NULL)
diag_cntl_send_msg_mask(peripheral, range=NULL)
diag_cmd_get_msg_mask(range = NULL, mask);
// range is NULL
int diag_cmd_get_msg_mask(struct diag_ssid_range_t *range, uint32_t **mask)
{
struct diag_msg_mask_t *msg_item = msg_mask.ptr;
uint32_t mask_size = 0;
int i;
for (i = 0; i < MSG_MASK_TBL_CNT; i++, msg_item++) {
if ((range->ssid_first < msg_item->ssid_first) ||
(range->ssid_first > msg_item->ssid_last_tools)) {
continue;
}
mask_size = msg_item->range * sizeof(**mask);
range->ssid_first = msg_item->ssid_first;
range->ssid_last = msg_item->ssid_last;
*mask = malloc(mask_size);
if (!*mask) {
warn("Failed to allocate event mask\n");
return -errno;
}
memcpy(*mask, msg_item->ptr, mask_size);
return 0;
}
return 1;
}
When following the code path for the extended message configurations, the code should run into a NULL-deref when using
DIAG_CMD_EXTENDED_MESSAGE_CONFIGURATION and DIAG_CMD_OP_SET_ALL_MSG_MASK with a non-zero mask.
Call path:
handle_extended_message_configuration() peripheral_broadcast_msg_mask(range = NULL) diag_cntl_send_msg_mask(peripheral, range=NULL) diag_cmd_get_msg_mask(range = NULL, mask);// range is NULL int diag_cmd_get_msg_mask(struct diag_ssid_range_t *range, uint32_t **mask) { struct diag_msg_mask_t *msg_item = msg_mask.ptr; uint32_t mask_size = 0; int i; for (i = 0; i < MSG_MASK_TBL_CNT; i++, msg_item++) { if ((range->ssid_first < msg_item->ssid_first) || (range->ssid_first > msg_item->ssid_last_tools)) { continue; } mask_size = msg_item->range * sizeof(**mask); range->ssid_first = msg_item->ssid_first; range->ssid_last = msg_item->ssid_last; *mask = malloc(mask_size); if (!*mask) { warn("Failed to allocate event mask\n"); return -errno; } memcpy(*mask, msg_item->ptr, mask_size); return 0; } return 1; }