reject non-XYZ/Lab PCS profiles

Change-Id: Ifa60806ec5643605c18b20c0eaf74eb4bc123e2d
Reviewed-on: https://skia-review.googlesource.com/120426
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/profiles/misc/bad_pcs.icc b/profiles/misc/bad_pcs.icc
new file mode 100644
index 0000000..48a509d
--- /dev/null
+++ b/profiles/misc/bad_pcs.icc
Binary files differ
diff --git a/profiles/misc/bad_pcs.icc.txt b/profiles/misc/bad_pcs.icc.txt
new file mode 100644
index 0000000..979baac
--- /dev/null
+++ b/profiles/misc/bad_pcs.icc.txt
@@ -0,0 +1 @@
+Unable to parse ICC profile
diff --git a/src/ICCProfile.c b/src/ICCProfile.c
index b4ee20b..42c942b 100644
--- a/src/ICCProfile.c
+++ b/src/ICCProfile.c
@@ -703,6 +703,11 @@
         }
     }
 
+    if (profile->pcs != make_signature('X', 'Y', 'Z', ' ') &&
+        profile->pcs != make_signature('L', 'a', 'b', ' ')) {
+        return false;
+    }
+
     bool pcs_is_xyz = profile->pcs == make_signature('X', 'Y', 'Z', ' ');
 
     // Pre-parse commonly used tags.
diff --git a/tests.c b/tests.c
index 6e56c4d..d79e6c1 100644
--- a/tests.c
+++ b/tests.c
@@ -500,6 +500,7 @@
 
     // Bad profiles found inn the wild
     { "profiles/misc/ColorGATE_Sihl_PhotoPaper.icc", NULL }, // Broken tag table, and A2B0 fails to parse
+    { "profiles/misc/bad_pcs.icc",                   NULL }, // PCS is 'RGB '
 
     // fuzzer generated profiles that found parsing bugs