From c4015677fec20aae0f0178648bb955ca4c897b0b Mon Sep 17 00:00:00 2001 From: Ben Gamari <ben@smart-cactus.org> Date: Sun, 8 Sep 2019 09:08:26 -0400 Subject: [PATCH] stub: Avoid strcpy overflow --- stub/cbits/stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stub/cbits/stub.cpp b/stub/cbits/stub.cpp index 1decbd7f..649e9d9d 100644 --- a/stub/cbits/stub.cpp +++ b/stub/cbits/stub.cpp @@ -509,7 +509,7 @@ void serve(void) { local.sun_family = AF_UNIX; const char* sock = getenv("GHC_DEBUG_SOCKET"); if (sock == NULL){ sock = "/tmp/ghc-debug"; } - strcpy(local.sun_path, sock); + strncpy(local.sun_path, sock, sizeof(local.sun_path)); unlink(local.sun_path); if (bind(s, (struct sockaddr *) &local, sizeof(local)) != 0) { barf("bind failed"); -- GitLab