Merge branch 'jk/format-person-part-buffer-limit'

Avoid buffer overflow in format_person_part() function
This commit is contained in:
Junio C Hamano 2012-05-25 12:06:16 -07:00
Родитель 407abbabe5 c9b4e9e5b6
Коммит 9972c8ea49
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -550,8 +550,10 @@ static size_t format_person_part(struct strbuf *sb, char part,
mail_end = s.mail_end; mail_end = s.mail_end;
if (part == 'N' || part == 'E') { /* mailmap lookup */ if (part == 'N' || part == 'E') { /* mailmap lookup */
strlcpy(person_name, name_start, name_end - name_start + 1); snprintf(person_name, sizeof(person_name), "%.*s",
strlcpy(person_mail, mail_start, mail_end - mail_start + 1); (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)); mailmap_name(person_mail, sizeof(person_mail), person_name, sizeof(person_name));
name_start = person_name; name_start = person_name;
name_end = name_start + strlen(person_name); name_end = name_start + strlen(person_name);