{ "out-numeric", BT_HAL_MESH_AUTH_NUMERIC_DISPLAY},
{ "out-alpha", BT_HAL_MESH_AUTH_ALPHANUMERIC_DISPLAY},
{ "static-oob", BT_HAL_MESH_AUTH_REQ_OOB_STATIC_KEY_INPUT},
+ { "unknown", BT_HAL_MESH_UNKNOWN_AUTH_METHOD},
};
if (len == strlen(auth_table[i].action) &&
!strcmp(str, auth_table[i].action))
break;
-
- return auth_table[i].auth_type;
+ if (i < sz) {
+ return auth_table[i].auth_type;
+ } else {
+ ERR("Mesh : Not A Proper Authentication Type!");
+ return BT_HAL_MESH_UNKNOWN_AUTH_METHOD;
+ }
}
enum mesh_dbus_interface_e {
}
INFO("Mesh:[OUT] AlphaNumeric Authentication: Value [%s]", str);
- ev.auth_type = BT_HAL_MESH_AUTH_ALPHANUMERIC_DISPLAY;
+ ev.auth_type = __mesh_get_authentication_type(str);
+ if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD)
+ return l_dbus_message_new_error(msg, dbus_err_fail, NULL);
g_strlcpy(ev.auth_value, str, sizeof(ev.auth_value));
if (mesh_event_cb)
INFO("Mesh:[OUT] Numeric Authentication type [%s] value [%u]", str, n);
auth_value = l_strdup_printf("%u",n);
ev.auth_type = __mesh_get_authentication_type(str);
+ if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD)
+ return l_dbus_message_new_error(msg, dbus_err_fail, NULL);
g_strlcpy(ev.auth_value, auth_value, sizeof(ev.auth_value));
if (mesh_event_cb)
INFO("Mesh:[IN] Numeric Authentication type [%s]", str);
ev.auth_type = __mesh_get_authentication_type(str);
+ if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD)
+ return l_dbus_message_new_error(msg, dbus_err_fail, NULL);
agent_msg = msg;
l_dbus_message_ref(msg);
if (mesh_event_cb)
INFO("Mesh: [IN] AlphaNumeric Authentication type [%s]", str);
ev.auth_type = __mesh_get_authentication_type(str);
+ if (ev.auth_type == BT_HAL_MESH_UNKNOWN_AUTH_METHOD)
+ return l_dbus_message_new_error(msg, dbus_err_fail, NULL);
agent_msg = msg;
l_dbus_message_ref(msg);
if (mesh_event_cb)
l1 = g_slist_find_custom(app->elements,
GUINT_TO_POINTER(src_elem_idx),
__compare_element_index);
+ if (!l1)
+ return BT_STATUS_FAIL;
elem = l1->data;
req = l_new(struct configuration_request, 1);
jentry = json_object_array_get_idx(jmodelarray, i);
str = json_object_get_string(jentry);
/* Only standard models are handled now */
- if (sscanf(str, "%04hx", models[i]) != 1)
+ if (sscanf(str, "%04hx", models[i]) != 1) {
+ for (int j =0 ; j < sz; j++)
+ g_free(models[j]);
+ g_free(models);
return NULL;
+ }
}
/* TODO: Need to handle vendor models */
*num_models = sz;
sz = read(fd, str, st.st_size);
if (sz != st.st_size) {
BT_ERR("Mesh: Failed to read configuration file [%s]", file_name);
+ g_free(str);
return NULL;
}
/* Extract Period */
param.period = data[7];
+ if (!cmd)
+ break;
if (cmd->opcode == MESH_OPCODE_CONFIG_MODEL_PUB_GET)
__bt_mesh_handle_pending_dev_config_request_info(result,
_bt_mesh_util_convert_string_to_hex(req->net_uuid, strlen(req->net_uuid), net_uuid.uuid, 16);
- if (req->pub_addr > MESH_ALL_NODES_ADDRESS)
- return BLUETOOTH_ERROR_INVALID_PARAM;
-
+ if (req->pub_addr == MESH_ALL_NODES_ADDRESS)
+ BT_INFO("Mesh: Setting Publication to ALL Node Address");
if (!MESH_IS_GROUP(req->pub_addr) && !MESH_IS_VIRTUAL(req->pub_addr) &&
req->pub_addr != MESH_UNASSIGNED_ADDRESS) {
int i;
line = g_malloc(strlen(prefix) + (16 * 3) + 2);
- sprintf(line, "%s ", prefix);
+ snprintf(line, strlen(prefix), "%s ", prefix);
bytes = line + strlen(prefix) + 1;
for (i = 0; i < len; ++i) {
- sprintf(bytes, "%2.2x ", data[i]);
+ snprintf(bytes, 4, "%2.2x ", data[i]);
if ((i + 1) % 16) {
bytes += 3;
} else {