summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-05-25 12:06:16 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-05-25 12:06:16 -0700
commit9972c8ea49ea95a841fd35fe847bc1062abe5a44 (patch)
tree344a6bfdb89aa53b5a56de7ff9d59a019c0f9fbc
parentMerge branch 'jk/pretty-commit-header-incomplete-line' (diff)
parentpretty: avoid buffer overflow in format_person_part (diff)
downloadtgif-9972c8ea49ea95a841fd35fe847bc1062abe5a44.tar.xz
Merge branch 'jk/format-person-part-buffer-limit'
Avoid buffer overflow in format_person_part() function
-rw-r--r--pretty.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pretty.c b/pretty.c
index dc57e5b329..8b1ea9ffad 100644
--- a/pretty.c
+++ b/pretty.c
@@ -550,8 +550,10 @@ static size_t format_person_part(struct strbuf *sb, char part,
mail_end = s.mail_end;
if (part == 'N' || part == 'E') { /* mailmap lookup */
- strlcpy(person_name, name_start, name_end - name_start + 1);
- strlcpy(person_mail, mail_start, mail_end - mail_start + 1);
+ snprintf(person_name, sizeof(person_name), "%.*s",
+ (int)(name_end - name_start), name_start);
+ snprintf(person_mail, sizeof(person_mail), "%.*s",
+ (int)(mail_end - mail_start), mail_start);
mailmap_name(person_mail, sizeof(person_mail), person_name, sizeof(person_name));
name_start = person_name;
name_end = name_start + strlen(person_name);