aboutsummaryrefslogtreecommitdiff
path: root/t/lib-chunk.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-10-23 13:56:36 -0700
committerJunio C Hamano <gitster@pobox.com>2023-10-23 13:56:36 -0700
commitf32af12ceec1c19d8a8a7874523d3a7ceef6eebf (patch)
tree9078d206b9956c89334901fd04f8a884f01379d6 /t/lib-chunk.sh
parentceadf0f3cf51550166a387ec8508bb55e7883057 (diff)
parent7538f9d89b001be33a1b682b5cf207c4ba8fd8c5 (diff)
downloadgit-f32af12ceec1c19d8a8a7874523d3a7ceef6eebf.tar.xz
Merge branch 'jk/chunk-bounds'
The codepaths that read "chunk" formatted files have been corrected to pay attention to the chunk size and notice broken files. * jk/chunk-bounds: (21 commits) t5319: make corrupted large-offset test more robust chunk-format: drop pair_chunk_unsafe() commit-graph: detect out-of-order BIDX offsets commit-graph: check bounds when accessing BIDX chunk commit-graph: check bounds when accessing BDAT chunk commit-graph: bounds-check generation overflow chunk commit-graph: check size of generations chunk commit-graph: bounds-check base graphs chunk commit-graph: detect out-of-bounds extra-edges pointers commit-graph: check size of commit data chunk midx: check size of revindex chunk midx: bounds-check large offset chunk midx: check size of object offset chunk midx: enforce chunk alignment on reading midx: check size of pack names chunk commit-graph: check consistency of fanout table midx: check size of oid lookup chunk commit-graph: check size of oid fanout chunk midx: stop ignoring malformed oid fanout chunk t: add library for munging chunk-format files ...
Diffstat (limited to 't/lib-chunk.sh')
-rw-r--r--t/lib-chunk.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/t/lib-chunk.sh b/t/lib-chunk.sh
new file mode 100644
index 0000000000..a7cd9c3c6d
--- /dev/null
+++ b/t/lib-chunk.sh
@@ -0,0 +1,17 @@
+# Shell library for working with "chunk" files (commit-graph, midx, etc).
+
+# corrupt_chunk_file <fn> <chunk> <offset> <bytes>
+#
+# Corrupt a chunk-based file (like a commit-graph) by overwriting the bytes
+# found in the chunk specified by the 4-byte <chunk> identifier. If <offset> is
+# "clear", replace the chunk entirely. Otherwise, overwrite data <offset> bytes
+# into the chunk.
+#
+# The <bytes> are interpreted as pairs of hex digits (so "000000FE" would be
+# big-endian 254).
+corrupt_chunk_file () {
+ fn=$1; shift
+ perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
+ "$@" <"$fn" >"$fn.tmp" &&
+ mv "$fn.tmp" "$fn"
+}