void NanDbusHandler::registerHandler(NanDbusManager *dbusManager)
{
NAN_LOGD("registerHandler");
-
+
if (dbusManager == nullptr) {
NAN_LOGE("dbusManager is nullptr");
return;
config->setDbusResource(NULL, NULL);
serviceProvider->disable(config, data->clientId);
}
-
+
g_free(data->clientConnName);
g_free(data);
}
// TODO:
// config->securityConfig.cipherType = getCipherType()
config->securityConfig.securityType = NAN_SECURITY_TYPE_PASSPHRASE;
- config->securityConfig.keyLen = strlen(psk);
- memcpy(config->securityConfig.passphrase, psk, config->securityConfig.keyLen);
+ auto len = strlen(psk);
+ if (len > NAN_MAX_PASSPHRASE_LEN) {
+ NAN_LOGE("Invalid psk length[%ld]", len);
+ return false;
+ }
+ config->securityConfig.keyLen = len;
+ memcpy(config->securityConfig.passphrase, psk, config->securityConfig.keyLen);
NanError ret = serviceProvider->openDataPath(config,
clientId, pubSubId, peerId, (NanDataPathRole)role);
wifi_error ret = WIFI_ERROR_NONE;
loadHalLibrary(HAL_LIBRARY);
-
+
ret = initWifiVendorHalFuncTable(&mFunctionTable);
if (ret != WIFI_SUCCESS) {
NAN_LOGE("Failed to initialize legacy HAL function table [%d]", ret);
nanEnableReq->config_nss = config->configNss;
nanEnableReq->nss = config->nss;
-
+
nanEnableReq->config_enable_ranging = config->configEnableRanging;
nanEnableReq->enable_ranging = config->enableRanging;
nanPublishReq->rssi_threshold_flag = config->useRssiThreshold;
nanPublishReq->connmap = 0;
- /*
+ /*
Set/Enable corresponding bits to disable any indications that follow a publish.
BIT0(0x1) - Disable publish termination indication.
BIT1(0x2) - Disable match expired indication. // 0x2
- BIT2(0x4) - Disable followUp indication received (OTA).
+ BIT2(0x4) - Disable followUp indication received (OTA).
BIT3(0x8) - Disable publishReplied indication.
*/
nanPublishReq->recv_indication_cfg = 0;
config->autoAcceptDataPathRequest ?
NAN_SERVICE_ACCEPT_POLICY_ALL : NAN_SERVICE_ACCEPT_POLICY_NONE;
nanPublishReq->cipher_type = 0;
-
- /*
+
+ /*
TODO: Ranging
*/
if (config->enableRanging) {
nanTransmitFollowupReq->publish_subscribe_id = pubSubId;
nanTransmitFollowupReq->requestor_instance_id = config->requestorId;
-
+
memcpy(&nanTransmitFollowupReq->addr, config->addr, NAN_MAC_ADDR_LEN);
nanTransmitFollowupReq->priority =
NanDataPathInitiatorRequest* NanHal::convertDataPathConfigToLegacyRequest(std::shared_ptr<DataPathConfig> config)
{
- NanDataPathInitiatorRequest *ndpInitiatorReq
+ NanDataPathInitiatorRequest *ndpInitiatorReq
= (NanDataPathInitiatorRequest *)calloc(1, sizeof(NanDataPathInitiatorRequest));
if (!ndpInitiatorReq) {
NAN_LOGE("Out of memory");
break;
}
- ndpInitiatorReq->service_name_len = strlen(config->serviceName);
+ auto len = strlen(config->serviceName);
+ if (len > NAN_MAX_SERVICE_NAME_LEN) {
+ NAN_LOGE("Invalid parameter: ndpInitiatorReq->service_name_len[%ld]", len);
+ free(ndpInitiatorReq);
+ return nullptr;
+ }
+ ndpInitiatorReq->service_name_len = len;
memcpy(&ndpInitiatorReq->service_name,
config->serviceName, ndpInitiatorReq->service_name_len);
break;
}
- ndpIndicationResp->service_name_len = strlen(config->serviceName);
+ auto len = strlen(config->serviceName);
+ if (len > NAN_MAX_SERVICE_NAME_LEN) {
+ NAN_LOGE("Invalid parameter: ndpIndicationResp->service_name_len[%ld]", len);
+ free(ndpIndicationResp);
+ return nullptr;
+ }
+ ndpIndicationResp->service_name_len = len;
memcpy(&ndpIndicationResp->service_name,
config->serviceName, ndpIndicationResp->service_name_len);