Commit 89bd4ddb by Edward Thomson

diff_generate: validate oid file size

Index entries are 32 bit unsigned ints, not `size_t`s.
parent fd9d4e28
......@@ -564,14 +564,14 @@ int git_diff__oid_for_file(
{
git_index_entry entry;
if (!git__is_sizet(size)) {
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_t)size;
entry.file_size = (uint32_t)size;
entry.path = (char *)path;
return git_diff__oid_for_entry(out, diff, &entry, mode, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment