Skip to content

Commit aa0b4b1

Browse files
committed
fix buffer overflow in test_security_dir
Signed-off-by: Abby Xu <[email protected]>
1 parent 64610d2 commit aa0b4b1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

rcl/test/rcl/test_security_directory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ TEST_F(TestGetSecureRoot, successScenarios) {
109109
TEST_SECURITY_DIRECTORY_RESOURCES_DIR_NAME, allocator);
110110
std::string putenv_input = ROS_SECURITY_ROOT_DIRECTORY_VAR_NAME "=";
111111
putenv_input += base_lookup_dir_fqn;
112-
memcpy(g_envstring, putenv_input.c_str(), sizeof(g_envstring) - 1);
112+
memcpy(g_envstring, putenv_input.c_str(), std::min(putenv_input.length(), sizeof(g_envstring) - 1));
113113
putenv_wrapper(g_envstring);
114114
/* --------------------------
115115
* Namespace : Root

0 commit comments

Comments
 (0)