From a65447e81444163986a6b7ebc5bb6820a98b5b6f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 7 Sep 2015 18:18:12 +0200 Subject: fail if socket pathname is too long MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mds.c b/src/mds.c index d9a4c9c..2a7e415 100644 --- a/src/mds.c +++ b/src/mds.c @@ -184,6 +184,8 @@ int main(int argc_, char** argv_) /* Create display socket. */ xsnprintf(pathname, "%s/%u.socket", MDS_RUNTIME_ROOT_DIRECTORY, display); address.sun_family = AF_UNIX; + if (strlen(pathname) >= sizeof(address.sun_path)) + fail_if ((errno = ENAMETOOLONG)); strcpy(address.sun_path, pathname); unlink(pathname); fail_if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0); -- cgit v1.2.3-70-g09d2