aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rerere.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/rerere.c b/rerere.c
index 7db5b54838..6fd8c5d3af 100644
--- a/rerere.c
+++ b/rerere.c
@@ -125,13 +125,20 @@ static void rerere_io_putconflict(int ch, int size, struct rerere_io *io)
char buf[64];
while (size) {
- if (size < sizeof(buf) - 2) {
+ if (size <= sizeof(buf) - 2) {
memset(buf, ch, size);
buf[size] = '\n';
buf[size + 1] = '\0';
size = 0;
} else {
int sz = sizeof(buf) - 1;
+
+ /*
+ * Make sure we will not write everything out
+ * in this round by leaving at least 1 byte
+ * for the next round, giving the next round
+ * a chance to add the terminating LF. Yuck.
+ */
if (size <= sz)
sz -= (sz - size) + 1;
memset(buf, ch, sz);