summaryrefslogtreecommitdiff
path: root/src/filebuf.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2012-09-11 23:38:16 +0200
committerVicent Marti <tanoku@gmail.com>2012-09-11 23:38:16 +0200
commit412293dcc95369f0a42ae9a94f30fe7328a5491c (patch)
tree200d4bb5fa8cc3f8f037486e2128479048b8384e /src/filebuf.c
parent5a409c44baf2c7c2bd36fb8e8c2d5b2ce5b1908b (diff)
parentc859184bb459d9801a394dc44f5b0b0e55453263 (diff)
downloadlibgit2-412293dcc95369f0a42ae9a94f30fe7328a5491c.tar.gz
Merge branch 'diff-crlf-filters' into development
Diffstat (limited to 'src/filebuf.c')
-rw-r--r--src/filebuf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/filebuf.c b/src/filebuf.c
index cfc8528e6..b9b908c8d 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -73,7 +73,7 @@ static int lock_file(git_filebuf *file, int flags)
if ((flags & GIT_FILEBUF_APPEND) && git_path_exists(file->path_original) == true) {
git_file source;
char buffer[2048];
- size_t read_bytes;
+ ssize_t read_bytes;
source = p_open(file->path_original, O_RDONLY);
if (source < 0) {
@@ -83,13 +83,18 @@ static int lock_file(git_filebuf *file, int flags)
return -1;
}
- while ((read_bytes = p_read(source, buffer, 2048)) > 0) {
+ while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) {
p_write(file->fd, buffer, read_bytes);
if (file->digest)
git_hash_update(file->digest, buffer, read_bytes);
}
p_close(source);
+
+ if (read_bytes < 0) {
+ giterr_set(GITERR_OS, "Failed to read file '%s'", file->path_original);
+ return -1;
+ }
}
return 0;