From 455f5ae69a20c14d6da49b82baaa4c2859baed63 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 7 Feb 2023 21:54:38 +0100 Subject: [PATCH] Limit the number of drawing primitives to 100000 to avoid people trashing the server with too complicated drawings --- boxes/drawing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boxes/drawing.py b/boxes/drawing.py index a3cca35..76ff1dd 100644 --- a/boxes/drawing.py +++ b/boxes/drawing.py @@ -34,6 +34,7 @@ class Surface: self._fname = fname self.parts: list[Any] = [] self._p = self.new_part("default") + self.count = 0 def set_metadata(self, metadata): self.metadata = metadata @@ -81,6 +82,9 @@ class Surface: return p def append(self, *path): + self.count += 1 + if self.count > 100000: + raise ValueError("Too many lines") self._p.append(*path) def stroke(self, **params):