aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dir.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 20ebe4cba2..6913003164 100644
--- a/dir.c
+++ b/dir.c
@@ -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.
@@ -1136,6 +1137,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;
}
@@ -1192,6 +1199,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;
}