[gnome-color-manager] Check the profile is a valid icc formatted file before we try to parse it
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Check the profile is a valid icc formatted file before we try to parse it
- Date: Sat, 31 Oct 2009 12:23:49 +0000 (UTC)
commit caf6f010e4fdb194faf609c8bea786cba639b934
Author: Richard Hughes <richard hughsie com>
Date: Sat Oct 31 12:22:56 2009 +0000
Check the profile is a valid icc formatted file before we try to parse it
src/gcm-profile.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index 4c6c983..54030b5 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -41,6 +41,7 @@ static void gcm_profile_finalize (GObject *object);
#define GCM_PROFILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_PROFILE, GcmProfilePrivate))
#define GCM_HEADER 0x00
+#define GCM_SIGNATURE 0x24
#define GCM_NUMTAGS 0x80
#define GCM_BODY 0x84
@@ -504,6 +505,26 @@ gcm_profile_load (GcmProfile *profile, const gchar *filename, GError **error)
goto out;
}
+ /* ensure we have the header */
+ if (length < 0x84) {
+ if (error != NULL)
+ *error = g_error_new (1, 0, "profile was not valid (file size too small)");
+ ret = FALSE;
+ goto out;
+ }
+
+ /* ensure this is a icc file */
+ if (data[GCM_SIGNATURE+0] != 'a' ||
+ data[GCM_SIGNATURE+1] != 'c' ||
+ data[GCM_SIGNATURE+2] != 's' ||
+ data[GCM_SIGNATURE+3] != 'p') {
+ data[GCM_SIGNATURE+4] = '\0';
+ if (error != NULL)
+ *error = g_error_new (1, 0, "not an ICC profile, signature is '%s', expecting 'acsp'", &data[GCM_SIGNATURE]);
+ ret = FALSE;
+ goto out;
+ }
+
/* get the number of tags in the file */
num_tags = gcm_parser_unencode_32 (data, GCM_NUMTAGS);
egg_debug ("number of tags: %i", num_tags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]