From 4693c4c6035c5c754f4ff7198e2f6bf4baeba0be Mon Sep 17 00:00:00 2001 From: Bram Oosterhuis Date: Thu, 1 Feb 2024 12:19:27 +0100 Subject: [PATCH] bluetooth: fix pincode copy. --- Source/bluetooth/HCISocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/bluetooth/HCISocket.cpp b/Source/bluetooth/HCISocket.cpp index d2eb9a2..a711b36 100644 --- a/Source/bluetooth/HCISocket.cpp +++ b/Source/bluetooth/HCISocket.cpp @@ -1245,8 +1245,8 @@ uint32_t ManagementSocket::UserPINCodeReply(const Address& remote, const Address Management::UserPINCodeReply command(_deviceId); command->addr.bdaddr = *remote.Data(); command->addr.type = type; - command->pin_len = std::max(pinCode.length(), sizeof(command->pin_code)); - ::strncpy(reinterpret_cast(command->pin_code), pinCode.c_str(), sizeof(command->pin_code)); + command->pin_len = std::min(pinCode.length(), sizeof(command->pin_code)); + ::memcpy(command->pin_code, pinCode.c_str(), std::min(pinCode.length(), sizeof(command->pin_code))); result = Exchange(MANAGMENT_TIMEOUT, command, command); commandResult = command.Result(); } else {