Code

Use strlcpy instead of strncpy in mailmap.c
authorAlex Riesen <raa.lkml@gmail.com>
Mon, 30 Apr 2007 22:22:53 +0000 (00:22 +0200)
committerJunio C Hamano <junkio@cox.net>
Mon, 30 Apr 2007 23:57:47 +0000 (16:57 -0700)
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
mailmap.c

index af187a38268b7e385885b3d990a99e6de9f569ba..c29e4e534925d250007507b3259855213b9500cc 100644 (file)
--- 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;