summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-06-23 16:23:59 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2019-11-22 15:13:05 +1100
commitfb2198db6b48ce3c5e3cecaa03ecb179c5a02382 (patch)
tree29e62fd409b5e8fe7d0af4de98d187cfd8641af2 /src/odb.c
parent4334b1779f661bf9a77c68c928e970cf9d25b477 (diff)
downloadlibgit2-fb2198db6b48ce3c5e3cecaa03ecb179c5a02382.tar.gz
futils_filesize: use `uint64_t` for object size
Instead of using a signed type (`off_t`) use `uint64_t` for the maximum size of files.
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/odb.c b/src/odb.c
index 2998a2d43..68d9a9a3f 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -320,20 +320,26 @@ int git_odb__hashlink(git_oid *out, const char *path)
int git_odb_hashfile(git_oid *out, const char *path, git_object_t type)
{
- git_object_size_t size;
- int result, fd = git_futils_open_ro(path);
- if (fd < 0)
+ uint64_t size;
+ int fd, error = 0;
+
+ if ((fd = git_futils_open_ro(path)) < 0)
return fd;
- if ((size = git_futils_filesize(fd)) < 0 || !git__is_sizet(size)) {
+ if ((error = git_futils_filesize(&size, fd)) < 0)
+ goto done;
+
+ if (!git__is_sizet(size)) {
git_error_set(GIT_ERROR_OS, "file size overflow for 32-bit systems");
- p_close(fd);
- return -1;
+ error = -1;
+ goto done;
}
- result = git_odb__hashfd(out, fd, (size_t)size, type);
+ error = git_odb__hashfd(out, fd, (size_t)size, type);
+
+done:
p_close(fd);
- return result;
+ return error;
}
int git_odb_hash(git_oid *id, const void *data, size_t len, git_object_t type)