diff options
author | Jiang Xin <worldhello.net@gmail.com> | 2014-04-21 14:02:03 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-04-23 00:01:52 -0700 |
commit | bccce0f8099fac6bcc80914726ddf43ca544b3c1 (patch) | |
tree | 0ff80a5be88d64458bbbfc5e12d797941b9f0cbd /t/t9154-git-svn-fancy-glob.sh | |
parent | Git 2.0-rc0 (diff) | |
download | tgif-bccce0f8099fac6bcc80914726ddf43ca544b3c1.tar.xz |
blame: fix broken time_buf paddings in relative timestamp
Command `git blame --date relative` aligns the date field with a
fixed-width (defined by blame_date_width), and if time_str is shorter
than that, it adds spaces for padding. But there are two bugs in the
following codes:
time_len = strlen(time_str);
...
memset(time_buf + time_len, ' ', blame_date_width - time_len);
1. The type of blame_date_width is size_t, which is unsigned. If
time_len is greater than blame_date_width, the result of
"blame_date_width - time_len" will never be a negative number, but a
really big positive number, and will cause memory overwrite.
This bug can be triggered if either l10n message for function
show_date_relative() in date.c is longer than 30 characters, then
`git blame --date relative` may exit abnormally.
2. When show blame information with relative time, the UTF-8 characters
in time_str will break the alignment of columns after the date field.
This is because the time_buf padding with spaces should have a
constant display width, not a fixed strlen size. So we should call
utf8_strwidth() instead of strlen() for width calibration.
Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9154-git-svn-fancy-glob.sh')
0 files changed, 0 insertions, 0 deletions