git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] index-helper: convert strncpy to memcpy

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Apr 10, 2016, 23:02 UTC
Message-ID
<570ADB68.8000705@ramsayjones.plus.com>
see commit eddda371 ("convert strncpy to memcpy", 24-09-2015).
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 index-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index-helper.c b/index-helper.c
index 4a8e2ae..00f286a 100644
--- a/index-helper.c
+++ b/index-helper.c
@@ -317,7 +317,7 @@ static int setup_socket(const char *socket_path)
 		return -1;
 
 	address.sun_family = AF_UNIX;
-	strncpy(address.sun_path, socket_path, sizeof(address.sun_path));
+	memcpy(address.sun_path, socket_path, len+1); /* include '\0' */
 
 	if (bind(fd, (struct sockaddr *) &address, sizeof(address)))
 		die_errno(_("failed to bind to socket %s"), socket_path);
-- 
2.8.0
Next: David Turner
Message 1 of 2 in “index-helper: convert strncpy to memcpy”
  1. 2/3 index-helper: convert strncpy to memcpyRamsay Jones, Apr 10, 2016
  2. David TurnerApr 11, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.