Merge "Replace instances of strncpy and sprintf in the wifi vendor HAL with strlcpy and snprintf." into tm-dev am: 98b2a2079c
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/17507356 Change-Id: I35df03b86e76b7459b4270f8eb83f73bf3a99d86 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
064297b3e1
2 changed files with 18 additions and 16 deletions
|
@ -1881,7 +1881,7 @@ bool convertHidlNanDataPathInitiatorRequestToLegacy(
|
|||
"ifaceName too long";
|
||||
return false;
|
||||
}
|
||||
strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
strlcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
legacy_request->ndp_cfg.security_cfg =
|
||||
(hidl_request.securityConfig.securityType != NanDataPathSecurityType::OPEN)
|
||||
? legacy_hal::NAN_DP_CONFIG_SECURITY
|
||||
|
@ -1958,7 +1958,7 @@ bool convertHidlNanDataPathInitiatorRequest_1_6ToLegacy(
|
|||
"ifaceName too long";
|
||||
return false;
|
||||
}
|
||||
strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
strlcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
legacy_request->ndp_cfg.security_cfg =
|
||||
(hidl_request.securityConfig.securityType != NanDataPathSecurityType::OPEN)
|
||||
? legacy_hal::NAN_DP_CONFIG_SECURITY
|
||||
|
@ -2039,7 +2039,7 @@ bool convertHidlNanDataPathIndicationResponseToLegacy(
|
|||
"ifaceName too long";
|
||||
return false;
|
||||
}
|
||||
strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
strlcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
legacy_request->ndp_cfg.security_cfg =
|
||||
(hidl_request.securityConfig.securityType != NanDataPathSecurityType::OPEN)
|
||||
? legacy_hal::NAN_DP_CONFIG_SECURITY
|
||||
|
@ -2114,7 +2114,7 @@ bool convertHidlNanDataPathIndicationResponse_1_6ToLegacy(
|
|||
"ifaceName too long";
|
||||
return false;
|
||||
}
|
||||
strncpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
strlcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str(), IFNAMSIZ + 1);
|
||||
legacy_request->ndp_cfg.security_cfg =
|
||||
(hidl_request.securityConfig.securityType != NanDataPathSecurityType::OPEN)
|
||||
? legacy_hal::NAN_DP_CONFIG_SECURITY
|
||||
|
|
|
@ -131,7 +131,7 @@ std::string getPredefinedP2pIfaceName() {
|
|||
if (strncmp(buffer.data(), P2P_MGMT_DEVICE_PREFIX, strlen(P2P_MGMT_DEVICE_PREFIX)) == 0) {
|
||||
/* Get the p2p parent interface name from p2p device interface name set
|
||||
* in property */
|
||||
strncpy(p2pParentIfname, buffer.data() + strlen(P2P_MGMT_DEVICE_PREFIX),
|
||||
strlcpy(p2pParentIfname, buffer.data() + strlen(P2P_MGMT_DEVICE_PREFIX),
|
||||
strlen(buffer.data()) - strlen(P2P_MGMT_DEVICE_PREFIX));
|
||||
if (property_get(kActiveWlanIfaceNameProperty, primaryIfaceName.data(), nullptr) == 0) {
|
||||
return buffer.data();
|
||||
|
@ -217,14 +217,15 @@ bool removeOldFilesInternal() {
|
|||
|
||||
// Helper function for |cpioArchiveFilesInDir|
|
||||
bool cpioWriteHeader(int out_fd, struct stat& st, const char* file_name, size_t file_name_len) {
|
||||
std::array<char, 32 * 1024> read_buf;
|
||||
ssize_t llen =
|
||||
sprintf(read_buf.data(), "%s%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X",
|
||||
kCpioMagic, static_cast<int>(st.st_ino), st.st_mode, st.st_uid, st.st_gid,
|
||||
static_cast<int>(st.st_nlink), static_cast<int>(st.st_mtime),
|
||||
static_cast<int>(st.st_size), major(st.st_dev), minor(st.st_dev),
|
||||
major(st.st_rdev), minor(st.st_rdev), static_cast<uint32_t>(file_name_len), 0);
|
||||
if (write(out_fd, read_buf.data(), llen) == -1) {
|
||||
const int buf_size = 32 * 1024;
|
||||
std::array<char, buf_size> read_buf;
|
||||
ssize_t llen = snprintf(
|
||||
read_buf.data(), buf_size, "%s%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X",
|
||||
kCpioMagic, static_cast<int>(st.st_ino), st.st_mode, st.st_uid, st.st_gid,
|
||||
static_cast<int>(st.st_nlink), static_cast<int>(st.st_mtime),
|
||||
static_cast<int>(st.st_size), major(st.st_dev), minor(st.st_dev), major(st.st_rdev),
|
||||
minor(st.st_rdev), static_cast<uint32_t>(file_name_len), 0);
|
||||
if (write(out_fd, read_buf.data(), llen < buf_size ? llen : buf_size - 1) == -1) {
|
||||
PLOG(ERROR) << "Error writing cpio header to file " << file_name;
|
||||
return false;
|
||||
}
|
||||
|
@ -282,10 +283,11 @@ size_t cpioWriteFileContent(int fd_read, int out_fd, struct stat& st) {
|
|||
|
||||
// Helper function for |cpioArchiveFilesInDir|
|
||||
bool cpioWriteFileTrailer(int out_fd) {
|
||||
std::array<char, 4096> read_buf;
|
||||
const int buf_size = 4096;
|
||||
std::array<char, buf_size> read_buf;
|
||||
read_buf.fill(0);
|
||||
if (write(out_fd, read_buf.data(),
|
||||
sprintf(read_buf.data(), "070701%040X%056X%08XTRAILER!!!", 1, 0x0b, 0) + 4) == -1) {
|
||||
ssize_t llen = snprintf(read_buf.data(), 4096, "070701%040X%056X%08XTRAILER!!!", 1, 0x0b, 0);
|
||||
if (write(out_fd, read_buf.data(), (llen < buf_size ? llen : buf_size - 1) + 4) == -1) {
|
||||
PLOG(ERROR) << "Error writing trailing bytes";
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue