Commit 66c7ba11 authored by Millian Poquet's avatar Millian Poquet

Assertion & improvement on socket filenames

parent 560f84b4
......@@ -50,7 +50,9 @@ void UnixDomainSocket::create_socket(const string & filename)
sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, filename.c_str(), sizeof(addr.sun_path)-1);
xbt_assert(filename.size() < sizeof(addr.sun_path), "Socket filename too long!");
strncpy(addr.sun_path, filename.c_str(), min(filename.size()+1,sizeof(addr.sun_path)));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment