Skip to content

Commit

Permalink
Merge branch 'jk/cap-exclude-file-size' into next
Browse files Browse the repository at this point in the history
An overly large ".gitignore" files are now rejected silently.

* jk/cap-exclude-file-size:
  dir.c: skip .gitignore, etc larger than INT_MAX
  • Loading branch information
gitster committed Jun 4, 2024
2 parents 3d8cb92 + a2bc523 commit 51c0d63
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "symlinks.h"
#include "trace2.h"
#include "tree.h"
#include "hex.h"

/*
* Tells read_directory_recursive how a file or directory should be treated.
Expand Down Expand Up @@ -1148,6 +1149,12 @@ static int add_patterns(const char *fname, const char *base, int baselen,
}
}

if (size > INT_MAX) {
warning("ignoring excessively large pattern file: %s", fname);
free(buf);
return -1;
}

add_patterns_from_buffer(buf, size, base, baselen, pl);
return 0;
}
Expand Down Expand Up @@ -1204,6 +1211,13 @@ int add_patterns_from_blob_to_list(
if (r != 1)
return r;

if (size > INT_MAX) {
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;
}
Expand Down

0 comments on commit 51c0d63

Please sign in to comment.