Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Die for an early EOF in a file reading loop
author
Heikki Orsila
<heikki.orsila@iki.fi>
Sun, 27 Apr 2008 14:07:24 +0000
(17:07 +0300)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 28 Apr 2008 05:24:55 +0000
(22:24 -0700)
The resulting data is zero terminated after the read loop, but
the subsequent loop that scans for '\n' will overrun the buffer.
Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
combine-diff.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
e8729f5
)
diff --git
a/combine-diff.c
b/combine-diff.c
index 0e19cbaacc1099fd69f7f2d9b4a17c94a327baa9..f1e7a4d5d98f8705b6a1a7a420dccc9ecad69d63 100644
(file)
--- a/
combine-diff.c
+++ b/
combine-diff.c
@@
-718,9
+718,9
@@
static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
result = xmalloc(len + 1);
while (sz < len) {
ssize_t done = xread(fd, result+sz, len-sz);
- if (done == 0)
-
break
;
- if (done < 0)
+ if (done == 0
&& sz != len
)
+
die("early EOF '%s'", elem->path)
;
+
else
if (done < 0)
die("read error '%s'", elem->path);
sz += done;
}