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

[PATCH] Use strlcpy instead of strncpy in mailmap.c

From
Alex Riesen <raa.lkml@gmail.com>
Date
Apr 30, 2007, 22:22 UTC
Message-ID
<20070430222253.GA5000@steel.home>

strncpy does not NUL-terminate output in case of output buffer too short, and map_email prototype (and usage) does not allow for figuring out what the length of the name is.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 mailmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mailmap.c b/mailmap.c
index af187a3..c29e4e5 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -80,7 +80,7 @@ int map_email(struct path_list *map, const char *email, char *name, int maxlen)
 		free(mailbuf);
 	if (item != NULL) {
 		const char *realname = (const char *)item->util;
-		strncpy(name, realname, maxlen);
+		strlcpy(name, realname, maxlen);
 		return 1;
 	}
 	return 0;
-- 
1.5.2.rc0.792.g7f4bd0
Message 1 of 1 in “Use strlcpy instead of strncpy in mailmap.c”
  1. Use strlcpy instead of strncpy in mailmap.cAlex Riesen, Apr 30, 2007

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.