Skip to content

pr-2253/dscho/coverity-fixes-overflow-v2

tagged this 23 Nov 22:13
This patch series is part of my effort to bring Git for Windows' Coverity
reports down to zero; Previous patch series have been merged in 347fe8a91b5
(Merge branch 'js/coverity-fixes', 2026-07-16), 0b75ef5168c (Merge branch
'js/coverity-fixes-null-safety', 2026-07-19), fcc8c931b53 (Merge branch
'js/coverity-unchecked-returns-fix', 2026-08-24) and 8bc9c7fcfd8 (Merge
branch 'js/coverity-fixes', 2026-10-03).

Changes since v1:

 * Most callers of read_in_full() and all callers of write_in_full() are now
   no longer restricted by the range of ssize_t.
 * The signed_mult_overflows() and mult_overflows() macros have been
   dropped.
 * Since the approxidate() function only deals with non-negative values, the
   complicated overflow check could been simplified.
 * Rebased to master, to avoid merge conflicts.

Johannes Schindelin (5):
  archive-tar: guard get_path_prefix against zero-length input
  http: use `size_t` for byte position in fwrite_sha1_file
  wrapper: avoid byte-count overflow in write_in_full()
  wrapper: add read_in_full_or_error()
  date: avoid overflow in approxidate relative-time multiplication

 Makefile                        |  1 +
 archive-tar.c                   |  2 +
 builtin/blame.c                 |  2 +-
 combine-diff.c                  |  6 +-
 date.c                          | 26 +++++++--
 dir.c                           |  2 +-
 grep.c                          |  2 +-
 http.c                          |  2 +-
 imap-send.c                     |  2 +-
 notes-merge.c                   | 13 +----
 refs/packed-backend.c           |  4 +-
 strbuf.c                        | 10 +++-
 t/meson.build                   |  1 +
 t/t0006-date.sh                 | 13 +++++
 t/unit-tests/u-reftable-stack.c |  2 +-
 t/unit-tests/u-wrapper.c        | 99 +++++++++++++++++++++++++++++++++
 wrapper.c                       | 56 ++++++++++++++-----
 wrapper.h                       | 14 ++++-
 18 files changed, 207 insertions(+), 50 deletions(-)
 create mode 100644 t/unit-tests/u-wrapper.c

base-commit: 7fb6055e678f800320d8ab8cd8f201d9493d1ba0

Submitted-As: https://lore.kernel.org/git/pull.2253.v2.git.1795472027.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2253.git.1791958171.gitgitgadget@gmail.com
Assets 2
Loading