Skip to contentSkip to conversation

Use strlcpy instead of strncpy in mailmap.c

PATCH New Alex Riesen 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use strlcpy instead of strncpy in mailmap.c

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.

---
 mailmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mailmap.c +1 -1
index af187a3..c29e4e5 100644
@@ -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;
Signature · 1 line
1.5.2.rc0.792.g7f4bd0