Invalid XPM file causes 500 error

Bug #865210 reported by Anthony Lenton on 2011-10-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Developer registration portal
Medium
Łukasz Czyżykowski

Bug Description

When simple invalid xpm files are submitted with an app, the app crashes and burns with the following traceback:

Traceback (most recent call last):
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/views/decorators/cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/srv/sc.ubuntu.com/production/software-center-agent/src/devportal/decorators.py", line 84, in inner_decorator
    return func(request, *args, **kwargs)
  File "/srv/sc.ubuntu.com/production/software-center-agent/src/devportal/views.py", line 326, in application_update
    if form.is_valid():
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/forms/forms.py", line 121, in is_valid
    return self.is_bound and not bool(self.errors)
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/forms/forms.py", line 112, in _get_errors
    self.full_clean()
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/forms/forms.py", line 267, in full_clean
    self._clean_fields()
  File "/srv/sc.ubuntu.com/production/software-center-agent/sourcecode/django/django/forms/forms.py", line 287, in _clean_fields
    value = getattr(self, 'clean_%s' % name)()
  File "/srv/sc.ubuntu.com/production/software-center-agent/src/softwarecenteragent/forms.py", line 91, in clean_icon_64
    return self._clean_icon(64)
  File "/srv/sc.ubuntu.com/production/software-center-agent/src/softwarecenteragent/forms.py", line 75, in _clean_icon
    icon = Image.open(icon_file)
  File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1976, in open
    return factory(fp, filename)
  File "/usr/lib/python2.6/dist-packages/PIL/ImageFile.py", line 91, in __init__
    self._open()
  File "/usr/lib/python2.6/dist-packages/PIL/XpmImagePlugin.py", line 93, in _open
    raise ValueError, "cannot read this XPM file"
ValueError: cannot read this XPM file

For example, you can try submitting a file called "test.xpm", containing "foo".

Changed in developer-portal:
status: New → Confirmed
importance: Undecided → Medium

The traceback here is from slightly broken XPM, more complicated than just "foo". When submitting "foo", the error is:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  92. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.6/django/views/decorators/cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py" in __call__
  78. return self.view_func(request, *args, **kwargs)
File "/srv/sc.ubuntu.com/production/software-center-agent/src/devportal/decorators.py" in inner_decorator
  83. return func(request, *args, **kwargs)
File "/srv/sc.ubuntu.com/production/software-center-agent/src/devportal/views.py" in application_update
  319. if form.is_valid():
File "/usr/lib/pymodules/python2.6/django/forms/forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "/usr/lib/pymodules/python2.6/django/forms/forms.py" in _get_errors
  111. self.full_clean()
File "/usr/lib/pymodules/python2.6/django/forms/forms.py" in full_clean
  243. value = getattr(self, 'clean_%s' % name)()
File "/srv/sc.ubuntu.com/production/software-center-agent/src/softwarecenteragent/forms.py" in clean_icon_16
  96. return self._clean_icon(16)
File "/srv/sc.ubuntu.com/production/software-center-agent/src/softwarecenteragent/forms.py" in _clean_icon
  72. icon = Image.open(icon_file)
File "/usr/lib/python2.6/dist-packages/PIL/Image.py" in open
  1980. raise IOError("cannot identify image file")

IOError instead of ValueError.

In the end I added handling both cases (IOError and ValueError).

tags: added: kb-defect sp-1
Changed in developer-portal:
status: Confirmed → Fix Committed
assignee: nobody → Łukasz Czyżykowski (lukasz-czyzykowski)
Changed in developer-portal:
milestone: none → 11.11
Changed in developer-portal:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers