diff mbox

[19/19] KVM test: kvm_preprocessing.py: verify PPM file validity before passing to PIL

Message ID 1252519932-30733-19-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Sept. 9, 2009, 6:12 p.m. UTC
Passing PIL an invalid PPM file makes it throw an IOError.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_preprocessing.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Comments

Lucas Meneghel Rodrigues Sept. 10, 2009, 3:24 a.m. UTC | #1
On Wed, Sep 9, 2009 at 3:12 PM, Michael Goldish <mgoldish@redhat.com> wrote:
> Passing PIL an invalid PPM file makes it throw an IOError.

This one was missing a ppm_utils import. Applied with minimal corrections.

> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm/kvm_preprocessing.py |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
> index 729e1d4..8809f31 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -273,9 +273,10 @@ def postprocess(test, params, env):
>                       " files to PNG format...")
>         try:
>             for f in glob.glob(os.path.join(test.debugdir, "*.ppm")):
> -                new_path = f.replace(".ppm", ".png")
> -                image = PIL.Image.open(f)
> -                image.save(new_path, format = 'PNG')
> +                if ppm_utils.image_verify_ppm_file(f):
> +                    new_path = f.replace(".ppm", ".png")
> +                    image = PIL.Image.open(f)
> +                    image.save(new_path, format='PNG')
>         except NameError:
>             pass
>
> --
> 1.5.4.1
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 729e1d4..8809f31 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -273,9 +273,10 @@  def postprocess(test, params, env):
                       " files to PNG format...")
         try:
             for f in glob.glob(os.path.join(test.debugdir, "*.ppm")):
-                new_path = f.replace(".ppm", ".png")
-                image = PIL.Image.open(f)
-                image.save(new_path, format = 'PNG')
+                if ppm_utils.image_verify_ppm_file(f):
+                    new_path = f.replace(".ppm", ".png")
+                    image = PIL.Image.open(f)
+                    image.save(new_path, format='PNG')
         except NameError:
             pass