NanDiscoveryResult discoveryEvent;
discoveryEvent.subId = event->publish_subscribe_id;
discoveryEvent.requestorId = event->requestor_instance_id;
+
+ if (event->service_specific_info_len < 0
+ || event->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ NAN_LOGE("Invalid service_specific_info length");
+ return;
+ }
+
memcpy(discoveryEvent.specificInfo, event->service_specific_info,
event->service_specific_info_len);
discoveryEvent.specificInfoLen = event->service_specific_info_len;
+
+ if (event->sdf_match_filter_len < 0
+ || event->sdf_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ NAN_LOGE("Invalid sdf_match_filter length");
+ return;
+ }
+
memcpy(discoveryEvent.matchFilter, event->sdf_match_filter,
event->sdf_match_filter_len);
discoveryEvent.matchFilterLen = event->sdf_match_filter_len;
NanFollowupEvent followupEvent;
followupEvent.pubSubId = event->publish_subscribe_id;
followupEvent.requestorId = event->requestor_instance_id;
+
+ if (event->service_specific_info_len < 0
+ || event->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ NAN_LOGE("Invalid service_specific_info length");
+ return;
+ }
+
memcpy(followupEvent.message, event->service_specific_info,
event->service_specific_info_len);
followupEvent.messageLen = event->service_specific_info_len;
NanDataPathRequestEvent dataPathEvent;
dataPathEvent.serviceId = event->service_instance_id;
dataPathEvent.dataPathId = event->ndp_instance_id;
+
+ if (event->app_info.ndp_app_info_len < 0
+ || event->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ NAN_LOGE("Invalid app_info length");
+ return;
+ }
+
memcpy(dataPathEvent.appInfo,
event->app_info.ndp_app_info,
event->app_info.ndp_app_info_len);
NanDataPathConfirmEvent dataPathConfirmEvent;
dataPathConfirmEvent.dataPathId = event->ndp_instance_id;
+
+ if (event->app_info.ndp_app_info_len < 0
+ || event->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ NAN_LOGE("Invalid app_info length");
+ return;
+ }
+
memcpy(dataPathConfirmEvent.appInfo,
event->app_info.ndp_app_info,
event->app_info.ndp_app_info_len);