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");
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) {
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;
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) {