Commit 29493be5 authored by Julien Muchembled's avatar Julien Muchembled

DMS: fix DoS in image conversion

parent eedee92c
......@@ -335,6 +335,11 @@ class Image(TextConvertableMixin, File, OFSImage):
parameter_list.append('-')
if format:
# Is there a way to make 'convert' fail if the format is unknown,
# instead of treating this whole parameter as an output file path?
# As a workaround, we run 'convert' in a non-writeable directory.
if '/' in format or os.access('/', os.W_OK):
raise ConversionError
parameter_list.append('%s:-' % format)
else:
parameter_list.append('-')
......@@ -350,6 +355,7 @@ class Image(TextConvertableMixin, File, OFSImage):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd='/',
close_fds=True)
try:
# XXX: The only portable way is to pass what stdin.write can accept,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment