[PATCH] bs_sheepdog.c: fix an unsafe strncpy() call

Hitoshi Mitake <[email protected]>
Newsgroups org.kernel.vger.stgt
Message-ID <[email protected]>
The strncpy() call doesn't take a null terminator into account. On
some environment, it conflicts with __builtin___strncpy_chk() and gcc
warns.

Signed-off-by: Hitoshi Mitake <[email protected]>
---
 usr/bs_sheepdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/bs_sheepdog.c b/usr/bs_sheepdog.c
index 1dda915..16547d0 100644
--- a/usr/bs_sheepdog.c
+++ b/usr/bs_sheepdog.c
@@ -398,7 +398,7 @@ static int connect_to_sdog_unix(const char *path)
 
 	memset(&un, 0, sizeof(un));
 	un.sun_family = AF_UNIX;
-	strncpy(un.sun_path, path, UNIX_PATH_MAX);
+	strncpy(un.sun_path, path, UNIX_PATH_MAX - 1);
 
 	ret = connect(fd, (const struct sockaddr *)&un, (socklen_t)sizeof(un));
 	if (ret < 0) {
-- 
1.8.1.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.