diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-20 22:40:38 +0000 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-25 22:36:38 +0000 |
| commit | c6cac733c147ff800f78e7dff81f90d93369ea68 (patch) | |
| tree | 8defbbcee3413d3524a0a98b6aa3172811e6cf7e /src/diff_stats.c | |
| parent | 3aa6d96a230d15620df0c6ea2ecaae54f5b49941 (diff) | |
| download | libgit2-c6cac733c147ff800f78e7dff81f90d93369ea68.tar.gz | |
blob: validate that blob sizes fit in a size_t
Our blob size is a `git_off_t`, which is a signed 64 bit int. This may
be erroneously negative or larger than `SIZE_MAX`. Ensure that the blob
size fits into a `size_t` before casting.
Diffstat (limited to 'src/diff_stats.c')
| -rw-r--r-- | src/diff_stats.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/diff_stats.c b/src/diff_stats.c index 9cd800651..a0681712f 100644 --- a/src/diff_stats.c +++ b/src/diff_stats.c @@ -54,7 +54,8 @@ int git_diff_file_stats__full_to_buf( size_t width) { const char *old_path = NULL, *new_path = NULL; - size_t padding, old_size, new_size; + size_t padding; + git_off_t old_size, new_size; old_path = delta->old_file.path; new_path = delta->new_file.path; @@ -96,7 +97,7 @@ int git_diff_file_stats__full_to_buf( if (delta->flags & GIT_DIFF_FLAG_BINARY) { if (git_buf_printf(out, - "Bin %" PRIuZ " -> %" PRIuZ " bytes", old_size, new_size) < 0) + "Bin %" PRId64 " -> %" PRId64 " bytes", old_size, new_size) < 0) goto on_error; } else { |
