Skip to content

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

tagged this 25 Nov 20:55
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 v2:

 * Fixed a grammar error and an overstatement in the "Changes since v1"
   section :-)
 * Accepted Junio's rewritten explanation in 2/5's commit message.
 * Clarified the design decision to abort on programing errors in 4/5's
   commit message.
 * Adjusted a few straggler ssize_t variables that can now safely be int or
   even be dropped.

Changes since v1:

 * Five 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 have 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 +-
 config.c                        | 14 ++---
 date.c                          | 26 +++++++--
 dir.c                           |  2 +-
 entry.c                         |  2 +-
 grep.c                          |  2 +-
 http.c                          |  2 +-
 imap-send.c                     |  2 +-
 notes-merge.c                   | 13 +----
 odb/streaming.c                 |  6 +-
 parallel-checkout.c             |  2 +-
 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 ++++-
 22 files changed, 218 insertions(+), 63 deletions(-)
 create mode 100644 t/unit-tests/u-wrapper.c

base-commit: 7fb6055e678f800320d8ab8cd8f201d9493d1ba0

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