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 {