diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-06-12 13:37:16 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-12 13:37:17 -0700 |
| commit | c2f79440acc0d24e5a8a61648cf92055cf4ca5c8 (patch) | |
| tree | 2688507a4338ccace103b84648c569b424e74913 /dir.c | |
| parent | b8bdb2f2835c9877120651cc9f22eaca6f8f66a8 (diff) | |
| parent | e7c3d1ddba0b3eb9d52780588636833055830c6f (diff) | |
| download | git-c2f79440acc0d24e5a8a61648cf92055cf4ca5c8.tar.xz | |
Merge branch 'jk/cap-exclude-file-size'
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
Diffstat (limited to 'dir.c')
| -rw-r--r-- | dir.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -30,6 +30,13 @@ #include "symlinks.h" #include "trace2.h" #include "tree.h" +#include "hex.h" + + /* + * The maximum size of a pattern/exclude file. If the file exceeds this size + * we will ignore it. + */ +#define PATTERN_MAX_FILE_SIZE (100 * 1024 * 1024) /* * Tells read_directory_recursive how a file or directory should be treated. @@ -1148,6 +1155,12 @@ static int add_patterns(const char *fname, const char *base, int baselen, } } + if (size > PATTERN_MAX_FILE_SIZE) { + warning("ignoring excessively large pattern file: %s", fname); + free(buf); + return -1; + } + add_patterns_from_buffer(buf, size, base, baselen, pl); return 0; } @@ -1204,6 +1217,13 @@ int add_patterns_from_blob_to_list( if (r != 1) return r; + if (size > PATTERN_MAX_FILE_SIZE) { + warning("ignoring excessively large pattern blob: %s", + oid_to_hex(oid)); + free(buf); + return -1; + } + add_patterns_from_buffer(buf, size, base, baselen, pl); return 0; } |
