[elbe-devel] [PATCH] Add file size > 1 GiB check
Manuel Traut
manut at linutronix.de
Wed Mar 13 17:33:47 CET 2019
On 16:47 Tue 12 Mar , bage at linutronix.de wrote:
> 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>
Reviewed-by: Manuel Traut <manut 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
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
More information about the elbe-devel
mailing list