[elbe-devel] [PATCH] Add file size > 1 GiB check

bage at linutronix.de bage at linutronix.de
Tue Mar 12 16:47:11 CET 2019


From: Bastian Germann <bage at linutronix.de>

Elbe's XML processing uses lxml which has a file size limit of 1.2 GiB.
Add a check for the XML file's size not being greater than 1 GiB.

Closes issue #184.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/validate.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/elbepack/validate.py b/elbepack/validate.py
index d03dd7ef..209823d0 100644
--- a/elbepack/validate.py
+++ b/elbepack/validate.py
@@ -5,6 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
+import os
 import sys
 
 from lxml import etree
@@ -12,6 +13,10 @@ from lxml.etree import XMLParser, parse
 
 
 def validate_xml(fname):
+    if os.path.getsize(fname) > 1<<30:
+        return ["%s is greater than 1 GiB. "
+                "Elbe does not support files of this size." % fname]
+
     schema_file = "https://www.linutronix.de/projects/Elbe/dbsfed.xsd"
     parser = XMLParser(huge_tree=True)
     schema_tree = etree.parse(schema_file)
-- 
2.11.0




More information about the elbe-devel mailing list