diff options
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -397,12 +397,18 @@ static const char *show_ident_date(const struct ident_split *ident, enum date_mode mode) { unsigned long date = 0; - int tz = 0; + long tz = 0; if (ident->date_begin && ident->date_end) date = strtoul(ident->date_begin, NULL, 10); - if (ident->tz_begin && ident->tz_end) - tz = strtol(ident->tz_begin, NULL, 10); + if (date_overflows(date)) + date = 0; + else { + if (ident->tz_begin && ident->tz_end) + tz = strtol(ident->tz_begin, NULL, 10); + if (tz >= INT_MAX || tz <= INT_MIN) + tz = 0; + } return show_date(date, tz, mode); } @@ -549,14 +555,13 @@ static char *get_header(const struct commit *commit, const char *msg, const char *line = msg; while (line) { - const char *eol = strchr(line, '\n'), *next; + const char *eol = strchrnul(line, '\n'), *next; if (line == eol) return NULL; - if (!eol) { + if (!*eol) { warning("malformed commit (header is missing newline): %s", sha1_to_hex(commit->object.sha1)); - eol = line + strlen(line); next = NULL; } else next = eol + 1; |