summaryrefslogtreecommitdiff
path: root/gitrepo.py
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2016-04-06 10:28:24 -0500
committerAndy Doan <andy.doan@linaro.org>2016-04-06 10:28:24 -0500
commit4541f54919c1e242af2fb7018b76f0ddb955afe4 (patch)
tree1d186d6ea709041138a08243455fd31b4c9aaebf /gitrepo.py
parent36bf774bfadf0822491a841d8f0b396ed0bde8ed (diff)
discard giant patches
We occasionally see giant patches come in, normally from libvirt releases such as: http://libvirt.org/git/?p=libvirt.git;a=commit;h=0086221cb377c7a1c2df58b8ee5eb8223f989765 Patchwork looks at patches line by line, and this consumes tons of memory and runs for hours blocking everything. This detects giant patches and safely discards them. Change-Id: I2403941c708c0923bbe143e783f5869da88f880d
Diffstat (limited to 'gitrepo.py')
-rw-r--r--gitrepo.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/gitrepo.py b/gitrepo.py
index b1464f7..977a0a8 100644
--- a/gitrepo.py
+++ b/gitrepo.py
@@ -128,4 +128,7 @@ class Repo(object):
# the patchwork parser code operates character by character so we must
# convert to unicode so it can be handled properly
patch = patch.decode('utf-8', errors='replace')
+ # Don't try and process >5Mb patches, they flood the server
+ if len(patch) > 5000000:
+ raise MemoryError('patch too large to process: %d' % len(patch))
return parse_patch(patch)[0]