summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaemin Ryu <jm77.ryu@samsung.com>2020-05-26 10:41:57 +0900
committerJaemin Ryu <jm77.ryu@samsung.com>2020-05-26 10:45:28 +0900
commitaab1ad8b3d6ef6f386d62825f2bebd7d731d3a32 (patch)
treef0af879d43504c1ae213d214885b16437f7c062f
parent723ec9261dc7b8283324b2fe89210a677f1433fc (diff)
downloadaudit-trail-accepted/tizen_6.0_unified.tar.gz
audit-trail-accepted/tizen_6.0_unified.tar.bz2
audit-trail-accepted/tizen_6.0_unified.zip
Change-Id: I4ff2c4059b41253c1fc1cf85f4458aecc12061be Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
-rw-r--r--tools/tests/groups/ipc.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/tests/groups/ipc.cpp b/tools/tests/groups/ipc.cpp
index fec0808..cfd5b66 100644
--- a/tools/tests/groups/ipc.cpp
+++ b/tools/tests/groups/ipc.cpp
@@ -188,6 +188,12 @@ public:
struct sockaddr_un addr;
std::thread client;
+ if (sockaddr.size() >= sizeof(sockaddr_un::sun_path)) {
+ Display::printError();
+ Display::printResult(Display::FAIL, "Address too long");
+ return;
+ }
+
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
Display::printError();
Display::printResult(Display::FAIL, "useSocket positive");
@@ -196,7 +202,7 @@ public:
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, sockaddr.c_str(), sizeof(sockaddr_un::sun_path));
+ strncpy(addr.sun_path, sockaddr.c_str(), sizeof(sockaddr_un::sun_path) - 1);
addr.sun_path[sizeof(sockaddr_un::sun_path) - 1] = '\0';
if (bind(fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
@@ -218,6 +224,13 @@ public:
std::string message("audit socket event testing");
struct sockaddr_un serveraddr;
+
+ if (sockaddr.size() >= sizeof(sockaddr_un::sun_path)) {
+ Display::printError();
+ Display::printResult(Display::FAIL, "Address too long");
+ return;
+ }
+
if ((clientFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
Display::printError();
return;
@@ -225,7 +238,7 @@ public:
memset(&serveraddr, 0, sizeof(serveraddr));
serveraddr.sun_family = AF_UNIX;
- strncpy(serveraddr.sun_path, sockaddr.c_str(), sizeof(sockaddr_un::sun_path));
+ strncpy(serveraddr.sun_path, sockaddr.c_str(), sizeof(sockaddr_un::sun_path) - 1);
serveraddr.sun_path[sizeof(sockaddr_un::sun_path) - 1] = '\0';
if (connect(clientFd, reinterpret_cast<struct sockaddr *>(&serveraddr), sizeof(serveraddr)) == -1) {