Skip to content

Commit 5522bba

Browse files
sunshinecogitster
authored andcommitted
sequencer: don't die() on bogus user-edited timestamp
read_author_ident() is careful to handle errors "gently" when parsing "rebase-merge/author-script" by printing a suitable warning and returning NULL; it never die()'s. One possible reason that parsing might fail is that "rebase-merge/author-script" has been hand-edited in such a way which corrupts it or the information it contains. However, read_author_ident() invokes fmt_ident() which is not so careful about failing "gently". It will die() if it encounters a malformed timestamp. Since read_author_ident() doesn't want to die() and since it's dealing with possibly hand-edited data, take care to avoid passing a bogus timestamp to fmt_ident(). A more "correctly engineered" fix would be to add a "gentle" version of fmt_ident(), however, such a change it outside the scope of the bug-fix series. If fmt_ident() ever does grow a "gentle" cousin, then the manual timestamp check added here can be retired. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 67f16e3 commit 5522bba

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sequencer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,15 @@ static const char *read_author_ident(struct strbuf *buf)
739739
return NULL;
740740
}
741741

742+
/* validate date since fmt_ident() will die() on bad value */
743+
if (parse_date(val[2], &out)){
744+
warning(_("invalid date format '%s' in '%s'"),
745+
val[2], rebase_path_author_script());
746+
strbuf_release(&out);
747+
return NULL;
748+
}
749+
750+
strbuf_reset(&out);
742751
strbuf_addstr(&out, fmt_ident(val[0], val[1], val[2], 0));
743752
strbuf_swap(buf, &out);
744753
strbuf_release(&out);

0 commit comments

Comments
 (0)