ref: 7fa741a4a2b7d50a232daec2b6fcb67afdabc2a5
parent: 0b4b45f393d13203752160695b3326d769cbead3
author: sirjofri <sirjofri@sirjofri.de>
date: Mon Apr 6 16:44:20 EDT 2026
some small checks
--- a/load.c
+++ b/load.c
@@ -145,6 +145,10 @@
u8int vmajor;
u8int vminor;
ulong n;
+ int hasdesc;
+ int hascprt;
+ int haswtpt;
+ int haschad;
prof = mallocz(sizeof(ICCprofile), 1);
if (!prof) {@@ -226,12 +230,37 @@
return nil;
}
+ hasdesc = haschad = hascprt = haswtpt = 0;
for (n = 0; n < prof->ntags; n++) {tag = &prof->tags[n];
td = &prof->tagdata[n*12] + 4;
tag->signature = iread32(td + 0);
tag->offset = iread32(td + 4);
- tag->size = iread32(td + 8);
+ tag->size = iread32(td + 8);
+
+ if (tag->signature == 0x64657363)
+ hasdesc++;
+ if (tag->signature == 0x63686164)
+ haschad++;
+ if (tag->signature == 0x63707274)
+ hascprt++;
+ if (tag->signature == 0x77747074)
+ haswtpt++;
+ }
+
+ if (!hasdesc) {+ werrstr("missing desc tag");+ free(prof->tags);
+ free(prof->tagdata);
+ free(prof);
+ return nil;
+ }
+ if (!hascprt) {+ werrstr("missing cprt tag");+ free(prof->tags);
+ free(prof->tagdata);
+ free(prof);
+ return nil;
}
return prof;
--- a/test/t.c
+++ b/test/t.c
@@ -82,7 +82,7 @@
for (n = 0; n < prof->ntags; n++) {fprint(2, " tag: %d\n", n);
asascii(buf, prof->tags[n].signature);
- fprint(2, " signature: %x (%4s)\n", prof->tags[n].signature, *buf ? buf : "");
+ fprint(2, " signature: 0x%x (%4s)\n", prof->tags[n].signature, *buf ? buf : "");
fprint(2, " offset: %d\n", prof->tags[n].offset);
fprint(2, " size: %d\n", prof->tags[n].size);
}
--
⑨