summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0a2c7ee)
raw | patch | inline | side by side (parent: 0a2c7ee)
author | Samuel Tardieu <sam@rfc1149.net> | |
Mon, 6 Oct 2008 17:28:41 +0000 (19:28 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 8 Oct 2008 14:38:48 +0000 (07:38 -0700) |
If we use pread() while at the end of the file, it will return 0, which is
not an error from the operating system point of view. In this case, errno
has not been set and must not be used.
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
not an error from the operating system point of view. In this case, errno
has not been set and must not be used.
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
index-pack.c | patch | blob | history |
diff --git a/index-pack.c b/index-pack.c
index 530d820370fb2b02a443873b8b9ddd0bcffcb5ec..c45ae20e8ffacefa43c5d0ab9daf0ff6ef181d4a 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
data = src;
do {
ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
- if (n <= 0)
+ if (n < 0)
die("cannot pread pack file: %s", strerror(errno));
+ if (!n)
+ die("premature end of pack file, %lu bytes missing",
+ len - rdy);
rdy += n;
} while (rdy < len);
data = xmalloc(obj->size);