Skip to content

Commit 1be224b

Browse files
gitsterspearce
authored andcommitted
builtin-mailinfo.c: check error status from rewind and ftruncate
A recent "cut at scissors" implementation rewinds and truncates the output file to store the message when it sees a scissors mark, but it did not check if these library calls succeeded. Signed-off-by: Junio C Hamano <[email protected]> [sp: Use fseek as rewind returns void] Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent e0ab002 commit 1be224b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

builtin-mailinfo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,10 @@ static int handle_commit_msg(struct strbuf *line)
785785

786786
if (use_scissors && is_scissors_line(line)) {
787787
int i;
788-
rewind(cmitmsg);
789-
ftruncate(fileno(cmitmsg), 0);
788+
if (fseek(cmitmsg, 0L, SEEK_SET))
789+
die_errno("Could not rewind output message file");
790+
if (ftruncate(fileno(cmitmsg), 0))
791+
die_errno("Could not truncate output message file at scissors");
790792
still_looking = 1;
791793

792794
/*

0 commit comments

Comments
 (0)