Skip to content

Commit c3ea051

Browse files
peffgitster
authored andcommitted
blame: don't overflow time buffer
When showing the raw timestamp, we format the numeric seconds-since-epoch into a buffer, followed by the timezone string. This string has come straight from the commit object. A well-formed object should have a timezone string of only a few bytes, but we could be operating on data pushed by a malicious user. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2857fb commit c3ea051

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ static const char *format_time(unsigned long time, const char *tz_str,
15981598
int tz;
15991599

16001600
if (show_raw_time) {
1601-
sprintf(time_buf, "%lu %s", time, tz_str);
1601+
snprintf(time_buf, sizeof(time_buf), "%lu %s", time, tz_str);
16021602
}
16031603
else {
16041604
tz = atoi(tz_str);

0 commit comments

Comments
 (0)