Here's a git patch for operations/external/png-load.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just feeling my way in here, and it seemed an easy fix to get rid of a warning that uncovered an error. fread return value was being ignored when checking header of a png file, and if the file was truncated it would have caused other errors. Better to catch the error and abort then instead of trying to parse the short header to decide if it's valid.

Patrick
>From 666f69e3f6c673e92a59cca62aea6f83f6f0ea3a Mon Sep 17 00:00:00 2001
From: Patrick Horgan <phorgan1@xxxxxxxxx>
Date: Tue, 9 Nov 2010 16:53:08 -0800
Subject: [PATCH] fread results were ignored but short file would be an error.  Added
 check.

---
 operations/external/png-load.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/operations/external/png-load.c b/operations/external/png-load.c
index 9f0d210..44128d8 100644
--- a/operations/external/png-load.c
+++ b/operations/external/png-load.c
@@ -74,7 +74,13 @@ gegl_buffer_import_png (GeglBuffer  *gegl_buffer,
       return -1;
     }
 
-  fread (header, 1, 8, infile);
+  if(fread (header, 1, 8, infile)!=8)
+    {
+      fclose (infile);
+      g_warning ("%s is not a valid png file", path);
+      return -1;
+    }
+
   if (png_sig_cmp (header, 0, 8))
     {
       fclose (infile);
@@ -249,7 +255,12 @@ static gint query_png (const gchar *path,
       return -1;
     }
 
-  fread (header, 1, 8, infile);
+  if(fread (header, 1, 8, infile)!=8)
+    {
+      fclose (infile);
+      g_warning ("%s is not a valid png file", path);
+      return -1;
+    }
   if (png_sig_cmp (header, 0, 8))
     {
       fclose (infile);
-- 
1.7.1

_______________________________________________
Gegl-developer mailing list
Gegl-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer

[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux