Restrict maximum size for seed corpus in fuzzer archives.
[email protected],[email protected]
[email protected]
Change-Id: I3929bc2a22537cc0f83aec69693e99b8ae10223a
Bug: 952036
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1565241
Commit-Queue: Abhishek Arya <[email protected]>
Reviewed-by: Max Moroz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#650389}
diff --git a/testing/libfuzzer/archive_corpus.py b/testing/libfuzzer/archive_corpus.py
index a3fd29f..6bf4b653 100755
--- a/testing/libfuzzer/archive_corpus.py
+++ b/testing/libfuzzer/archive_corpus.py
@@ -16,6 +16,8 @@
import warnings
import zipfile
+SEED_CORPUS_LIMIT_MB = 100
+
def main():
parser = argparse.ArgumentParser(description="Generate fuzzer config.")
@@ -26,6 +28,7 @@
args = parser.parse_args()
corpus_files = []
+ seed_corpus_path = args.output
for directory in args.corpus_directories:
if not os.path.exists(directory):
@@ -36,7 +39,7 @@
full_filename = os.path.join(dirpath, filename)
corpus_files.append(full_filename)
- with zipfile.ZipFile(args.output, 'w') as z:
+ with zipfile.ZipFile(seed_corpus_path, 'w') as z:
# Turn warnings into errors to interrupt the build: crbug.com/653920.
with warnings.catch_warnings():
warnings.simplefilter("error")
@@ -45,6 +48,10 @@
arcname = '%016d' % i
z.write(corpus_file, arcname)
+ if os.path.getsize(seed_corpus_path) > SEED_CORPUS_LIMIT_MB * 1024 * 1024:
+ print('Seed corpus %s exceeds maximum allowed size (%d MB).' %
+ (seed_corpus_path, SEED_CORPUS_LIMIT_MB))
+ sys.exit(-1)
if __name__ == '__main__':
main()