[Libguestfs] [PATCH] fish: do not overflow when copying the socket path

Pino Toscano ptoscano at redhat.com
Fri Aug 8 15:21:25 UTC 2014


---
 fish/rc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fish/rc.c b/fish/rc.c
index 8e22c53..c066d98 100644
--- a/fish/rc.c
+++ b/fish/rc.c
@@ -82,7 +82,8 @@ create_sockpath (pid_t pid, char *sockpath, size_t len,
   snprintf (sockpath, len, SOCKET_PATH, euid, pid);
 
   addr->sun_family = AF_UNIX;
-  strcpy (addr->sun_path, sockpath);
+  strncpy (addr->sun_path, sockpath, UNIX_PATH_MAX);
+  addr->sun_path[UNIX_PATH_MAX-1] = '\0';
 }
 
 static const socklen_t controllen = CMSG_LEN (sizeof (int));
-- 
1.9.3




More information about the Libguestfs mailing list