Skip to content

Commit

Permalink
fix buffer overflow in test_security_dir
Browse files Browse the repository at this point in the history
Signed-off-by: Abby Xu <abbyxu@amazon.com>
  • Loading branch information
xabxx committed May 2, 2019
1 parent 64610d2 commit 4a04173
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rcl/test/rcl/test_security_directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <gtest/gtest.h>

#include <string>
#include <algorithm>
#include "rcl/security_directory.h"
#include "rcutils/filesystem.h"

Expand Down Expand Up @@ -109,7 +110,8 @@ TEST_F(TestGetSecureRoot, successScenarios) {
TEST_SECURITY_DIRECTORY_RESOURCES_DIR_NAME, allocator);
std::string putenv_input = ROS_SECURITY_ROOT_DIRECTORY_VAR_NAME "=";
putenv_input += base_lookup_dir_fqn;
memcpy(g_envstring, putenv_input.c_str(), sizeof(g_envstring) - 1);
memcpy(g_envstring, putenv_input.c_str(),
std::min(putenv_input.length(), sizeof(g_envstring) - 1));
putenv_wrapper(g_envstring);
/* --------------------------
* Namespace : Root
Expand Down

0 comments on commit 4a04173

Please sign in to comment.