Commit 35897a48 authored by Kevin Qin's avatar Kevin Qin Committed by Commit Bot

Replace Microsoft Version of strcpy_s with std lib strcpy_s

Current OpenXR implementation use some strcpy_s without size, replace
them with std strcpy_s with a size parameter.

Fixed: 1029100
Change-Id: I872f8fe3d97f7a5356d6135085b1f08e76cd8952
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940876
Commit-Queue: Zheng Qin <zheqi@microsoft.com>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719820}
parent 073d3b15
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "device/gamepad/public/cpp/gamepads.h" #include "device/gamepad/public/cpp/gamepads.h"
#include "device/vr/openxr/openxr_util.h" #include "device/vr/openxr/openxr_util.h"
#include "device/vr/util/xr_standard_gamepad_builder.h" #include "device/vr/util/xr_standard_gamepad_builder.h"
...@@ -75,10 +76,12 @@ XrResult OpenXrController::Initialize( ...@@ -75,10 +76,12 @@ XrResult OpenXrController::Initialize(
XrActionSetCreateInfo action_set_create_info = { XrActionSetCreateInfo action_set_create_info = {
XR_TYPE_ACTION_SET_CREATE_INFO}; XR_TYPE_ACTION_SET_CREATE_INFO};
errno_t error = errno_t error = strcpy_s(action_set_create_info.actionSetName,
strcpy_s(action_set_create_info.actionSetName, action_set_name.c_str()); base::size(action_set_create_info.actionSetName),
action_set_name.c_str());
DCHECK(!error); DCHECK(!error);
error = strcpy_s(action_set_create_info.localizedActionSetName, error = strcpy_s(action_set_create_info.localizedActionSetName,
base::size(action_set_create_info.localizedActionSetName),
action_set_name.c_str()); action_set_name.c_str());
DCHECK(!error); DCHECK(!error);
...@@ -373,9 +376,13 @@ XrResult OpenXrController::CreateAction( ...@@ -373,9 +376,13 @@ XrResult OpenXrController::CreateAction(
XrActionCreateInfo action_create_info = {XR_TYPE_ACTION_CREATE_INFO}; XrActionCreateInfo action_create_info = {XR_TYPE_ACTION_CREATE_INFO};
action_create_info.actionType = type; action_create_info.actionType = type;
errno_t error = strcpy_s(action_create_info.actionName, action_name.data()); errno_t error =
strcpy_s(action_create_info.actionName,
base::size(action_create_info.actionName), action_name.data());
DCHECK(error == 0); DCHECK(error == 0);
error = strcpy_s(action_create_info.localizedActionName, action_name.data()); error = strcpy_s(action_create_info.localizedActionName,
base::size(action_create_info.localizedActionName),
action_name.data());
DCHECK(error == 0); DCHECK(error == 0);
RETURN_IF_XR_FAILED(xrCreateAction(action_set_, &action_create_info, action)); RETURN_IF_XR_FAILED(xrCreateAction(action_set_, &action_create_info, action));
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <directxmath.h> #include <directxmath.h>
#include <wrl.h> #include <wrl.h>
#include "base/stl_util.h"
#include "device/vr/openxr/openxr_util.h" #include "device/vr/openxr/openxr_util.h"
#include "device/vr/openxr/test/openxr_negotiate.h" #include "device/vr/openxr/test/openxr_negotiate.h"
#include "device/vr/openxr/test/openxr_test_helper.h" #include "device/vr/openxr/test/openxr_test_helper.h"
...@@ -431,8 +432,9 @@ XrResult xrEnumerateInstanceExtensionProperties( ...@@ -431,8 +432,9 @@ XrResult xrEnumerateInstanceExtensionProperties(
"XrExtensionProperties is nullptr"); "XrExtensionProperties is nullptr");
for (uint32_t i = 0; i < OpenXrTestHelper::NumExtensionsSupported(); i++) { for (uint32_t i = 0; i < OpenXrTestHelper::NumExtensionsSupported(); i++) {
properties[i].type = XR_TYPE_EXTENSION_PROPERTIES; properties[i].type = XR_TYPE_EXTENSION_PROPERTIES;
errno_t error = errno_t error = strcpy_s(properties[i].extensionName,
strcpy_s(properties[i].extensionName, OpenXrTestHelper::kExtensions[i]); base::size(properties[i].extensionName),
OpenXrTestHelper::kExtensions[i]);
DCHECK(error == 0); DCHECK(error == 0);
properties[i].extensionVersion = 1; properties[i].extensionVersion = 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment