pr-2174/dscho/coverity-fixes-null-safety-v2
tagged this
10 Jul 11:39
This is a continuation of the effort I started in the patch series that became js/coverity-fixes. This next batch adds guards to avoid dereferencing NULL pointers and accessing NULL file descriptors. Changes since v1: * Calling remote_tracking() no longer returns -1 when remote is NULL, but instead BUG()s out. * bisect_successful() returns with BISECT_FAILED instead of the -1 that only worked by happenstance. * The commit "revision: avoid dereferencing NULL in add_parents_only()" now comes with a regression test. * The commit "bisect: ensure non-NULL head before using it" no longer claims that the fixed bug can be triggered with the current code base. * The missing shallow commit's OID is no longer computed twice. * A follow-up commit was folded into this patch series that lets write_one_shallow() avoid the rolling buffers of oid_to_hex(), as suggested by Junio. It technically does not fit the goal of this patch series (fixing issues pointed out by Coverity), but was asked for explicitly. Johannes Schindelin (12): diffcore-break: guard against NULLed queue entries in merge loop diff: handle NULL return from repo_get_commit_tree() remote: guard `remote_tracking()` against NULL remote reftable/stack: guard against NULL list_file in stack_destroy mailsplit: move NULL check before first use of file handle bisect: handle NULL commit in `bisect_successful()` replay: die when --onto does not peel to a commit revision: avoid dereferencing NULL in `add_parents_only()` pack-bitmap: handle missing bitmap for base MIDX bisect: ensure non-NULL `head` before using it shallow: fix NULL dereference shallow: give write_one_shallow() its own hex buffer builtin/bisect.c | 9 ++++++++- builtin/diff.c | 10 +++++++--- builtin/mailsplit.c | 6 +++--- diffcore-break.c | 2 ++ pack-bitmap.c | 4 ++++ reftable/stack.c | 3 ++- remote.c | 2 ++ replay.c | 8 ++++++-- revision.c | 9 +++++++-- shallow.c | 7 ++++--- t/t0410-partial-clone.sh | 18 ++++++++++++++++++ 11 files changed, 63 insertions(+), 15 deletions(-) base-commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc Submitted-As: https://lore.kernel.org/git/pull.2174.v2.git.1783683577.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2174.git.1783590159.gitgitgadget@gmail.com