[stgt] [PATCH] bs_sheepdog.c: fix an unsafe strncpy() call
Hitoshi Mitake
mitake.hitoshi at gmail.com
Sun Nov 24 15:18:09 CET 2013
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 <mitake.hitoshi at lab.ntt.co.jp>
---
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
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list