Skip to contentSkip to conversation

bs_sheepdog.c: fix an unsafe strncpy() call

PATCH Applied Hitoshi Mitake 2 participants 2 messages Nov 24, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bs_sheepdog.c: fix an unsafe strncpy() call

The strncpy() call doesn't take a null terminator into account. On some environment, it conflicts with __builtin___strncpy_chk() and gcc warns.

---
 usr/bs_sheepdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
usr/bs_sheepdog.c +1 -1
index 1dda915..16547d0 100644
@@ -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) {
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 8 lines · On Sun, 24 Nov 2013 23:18:09 +0900 Hitoshi Mitake <[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.

---
 usr/bs_sheepdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.