Skip to content

Commit

Permalink
blame: don't overflow time buffer
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Dec 14, 2011
1 parent c2857fb commit c3ea051
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/blame.c
Expand Up @@ -1598,7 +1598,7 @@ static const char *format_time(unsigned long time, const char *tz_str,
int tz;

if (show_raw_time) {
sprintf(time_buf, "%lu %s", time, tz_str);
snprintf(time_buf, sizeof(time_buf), "%lu %s", time, tz_str);
}
else {
tz = atoi(tz_str);
Expand Down

0 comments on commit c3ea051

Please sign in to comment.