diff options
author | Jaemin Ryu <jm77.ryu@samsung.com> | 2020-05-26 10:41:57 +0900 |
---|---|---|
committer | Jaemin Ryu <jm77.ryu@samsung.com> | 2020-05-26 10:45:28 +0900 |
commit | aab1ad8b3d6ef6f386d62825f2bebd7d731d3a32 (patch) | |
tree | f0af879d43504c1ae213d214885b16437f7c062f | |
parent | 723ec9261dc7b8283324b2fe89210a677f1433fc (diff) | |
download | audit-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 |
Fix ASAN build errortizen_6.0.m2_releasesubmit/tizen_6.0_hotfix/20201103.114804submit/tizen_6.0_hotfix/20201102.192504submit/tizen_6.0/20201029.205104submit/tizen/20200526.072729accepted/tizen/unified/20200528.132954accepted/tizen/6.0/unified/hotfix/20201103.003149accepted/tizen/6.0/unified/20201030.114738tizen_6.0_hotfixtizen_6.0accepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unified
Change-Id: I4ff2c4059b41253c1fc1cf85f4458aecc12061be
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
-rw-r--r-- | tools/tests/groups/ipc.cpp | 17 |
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) { |