diff options
Diffstat (limited to 'src/diff_generate.c')
-rw-r--r-- | src/diff_generate.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/diff_generate.c b/src/diff_generate.c index acc6c341b..5579dc214 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -564,9 +564,14 @@ int git_diff__oid_for_file( { git_index_entry entry; + if (size < 0 || size > UINT32_MAX) { + git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'", path); + return -1; + } + memset(&entry, 0, sizeof(entry)); entry.mode = mode; - entry.file_size = size; + entry.file_size = (uint32_t)size; entry.path = (char *)path; return git_diff__oid_for_entry(out, diff, &entry, mode, NULL); @@ -628,7 +633,7 @@ int git_diff__oid_for_entry( error = git_odb__hashlink(out, full_path.ptr); diff->base.perf.oid_calculations++; } else if (!git__is_sizet(entry.file_size)) { - git_error_set(GIT_ERROR_OS, "file size overflow (for 32-bits) on '%s'", + git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'", entry.path); error = -1; } else if (!(error = git_filter_list_load(&fl, |