summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2019-11-25 11:41:58 -0800
committerAlessandro <ales.astone@gmail.com>2020-04-05 14:31:23 +0200
commitb49054a392220c29d1cb33b8868ac4008c41301d (patch)
treec19dfb0674cede17d12378965e2d62c6c171f0cb
parent892b49e429ca2c5faf86f25abe761a1ba9c2027b (diff)
downloadhardware_lineage_interfaces-b49054a392220c29d1cb33b8868ac4008c41301d.tar.gz
hardware_lineage_interfaces-b49054a392220c29d1cb33b8868ac4008c41301d.tar.bz2
hardware_lineage_interfaces-b49054a392220c29d1cb33b8868ac4008c41301d.zip
[AWARE] Protect string copy against buffer overflow
Fixes: 143789898 Test: (Unit) atest com.android.server.wifi Test: ACTS ThroughputTest:test_iperf_single_ndp_aware_only_ib Test: (VTS) atest VtsHalWifiApV1_4TargetTest Change-Id: I5b8aa1d9a6388fe20cb7e1cd6a76d5e59e14d099
-rw-r--r--wifi/1.0-legacy/hidl_struct_util.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/wifi/1.0-legacy/hidl_struct_util.cpp b/wifi/1.0-legacy/hidl_struct_util.cpp
index 2e4db70..d305c09 100644
--- a/wifi/1.0-legacy/hidl_struct_util.cpp
+++ b/wifi/1.0-legacy/hidl_struct_util.cpp
@@ -1819,7 +1819,13 @@ bool convertHidlNanDataPathInitiatorRequestToLegacy(
convertHidlNanDataPathChannelCfgToLegacy(
hidl_request.channelRequestType);
legacy_request->channel = hidl_request.channel;
- strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ if (strnlen(hidl_request.ifaceName.c_str(), IFNAMSIZ + 1) == IFNAMSIZ + 1) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "ifaceName too long";
+ return false;
+ }
+ strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(),
+ IFNAMSIZ + 1);
legacy_request->ndp_cfg.security_cfg =
(hidl_request.securityConfig.securityType !=
NanDataPathSecurityType::OPEN)
@@ -1900,7 +1906,13 @@ bool convertHidlNanDataPathIndicationResponseToLegacy(
? legacy_hal::NAN_DP_REQUEST_ACCEPT
: legacy_hal::NAN_DP_REQUEST_REJECT;
legacy_request->ndp_instance_id = hidl_request.ndpInstanceId;
- strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ if (strnlen(hidl_request.ifaceName.c_str(), IFNAMSIZ + 1) == IFNAMSIZ + 1) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "ifaceName too long";
+ return false;
+ }
+ strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(),
+ IFNAMSIZ + 1);
legacy_request->ndp_cfg.security_cfg =
(hidl_request.securityConfig.securityType !=
NanDataPathSecurityType::OPEN)