Git fork

Merge branch 'jk/cap-exclude-file-size' into maint-2.45

An overly large ".gitignore" files are now rejected silently.

* jk/cap-exclude-file-size:
dir.c: reduce max pattern file size to 100MB
dir.c: skip .gitignore, etc larger than INT_MAX

+40
+20
dir.c
··· 30 30 #include "symlinks.h" 31 31 #include "trace2.h" 32 32 #include "tree.h" 33 + #include "hex.h" 34 + 35 + /* 36 + * The maximum size of a pattern/exclude file. If the file exceeds this size 37 + * we will ignore it. 38 + */ 39 + #define PATTERN_MAX_FILE_SIZE (100 * 1024 * 1024) 33 40 34 41 /* 35 42 * Tells read_directory_recursive how a file or directory should be treated. ··· 1148 1155 } 1149 1156 } 1150 1157 1158 + if (size > PATTERN_MAX_FILE_SIZE) { 1159 + warning("ignoring excessively large pattern file: %s", fname); 1160 + free(buf); 1161 + return -1; 1162 + } 1163 + 1151 1164 add_patterns_from_buffer(buf, size, base, baselen, pl); 1152 1165 return 0; 1153 1166 } ··· 1203 1216 r = do_read_blob(oid, NULL, &size, &buf); 1204 1217 if (r != 1) 1205 1218 return r; 1219 + 1220 + if (size > PATTERN_MAX_FILE_SIZE) { 1221 + warning("ignoring excessively large pattern blob: %s", 1222 + oid_to_hex(oid)); 1223 + free(buf); 1224 + return -1; 1225 + } 1206 1226 1207 1227 add_patterns_from_buffer(buf, size, base, baselen, pl); 1208 1228 return 0;
+8
t/t0008-ignores.sh
··· 945 945 test_grep "unable to access.*gitignore" err 946 946 ' 947 947 948 + test_expect_success EXPENSIVE 'large exclude file ignored in tree' ' 949 + test_when_finished "rm .gitignore" && 950 + dd if=/dev/zero of=.gitignore bs=101M count=1 && 951 + git ls-files -o --exclude-standard 2>err && 952 + echo "warning: ignoring excessively large pattern file: .gitignore" >expect && 953 + test_cmp expect err 954 + ' 955 + 948 956 test_done
+12
t/t6112-rev-list-filters-objects.sh
··· 701 701 grep "blob:limit=1024" trace 702 702 ' 703 703 704 + test_expect_success EXPENSIVE 'large sparse filter file ignored' ' 705 + blob=$(dd if=/dev/zero bs=101M count=1 | 706 + git hash-object -w --stdin) && 707 + test_must_fail \ 708 + git rev-list --all --objects --filter=sparse:oid=$blob 2>err && 709 + cat >expect <<-EOF && 710 + warning: ignoring excessively large pattern blob: $blob 711 + fatal: unable to parse sparse filter data in $blob 712 + EOF 713 + test_cmp expect err 714 + ' 715 + 704 716 test_done