summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filter.c14
-rw-r--r--tests-clar/repo/init.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/filter.c b/src/filter.c
index 503f18555..9f866fe88 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -657,9 +657,17 @@ int git_filter_list_apply_to_blob(
git_filter_list *filters,
git_blob *blob)
{
- git_buf in = {
- (char *)git_blob_rawcontent(blob), 0, git_blob_rawsize(blob)
- };
+ git_buf in = GIT_BUF_INIT;
+ git_off_t rawsize = git_blob_rawsize(blob);
+
+ if (!git__is_sizet(rawsize)) {
+ giterr_set(GITERR_OS, "Blob is too large to filter");
+ return -1;
+ }
+
+ in.ptr = (char *)git_blob_rawcontent(blob);
+ in.asize = 0;
+ in.size = (size_t)rawsize;
if (filters)
git_oid_cpy(&filters->source.oid, git_blob_id(blob));
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index caa211e75..392be205b 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -382,7 +382,7 @@ static void assert_hooks_match(
cl_git_pass(git_buf_joinpath(&actual, repo_dir, hook_path));
cl_git_pass(git_path_lstat(actual.ptr, &st));
- cl_assert_equal_sz(expected_st.st_size, st.st_size);
+ cl_assert(expected_st.st_size == st.st_size);
if (GIT_MODE_TYPE(expected_st.st_mode) != GIT_FILEMODE_LINK) {
mode_t expected_mode =