Skip to content

Commit 3515c86

Browse files
committed
Update image.TGA.1.sg
- even more sanity checks, one fixed; modernised return result()
1 parent 16499cb commit 3515c86

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

db/Binary/image.TGA.1.sg

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ function detect(bShowType,bShowVersion,bShowOptions) {
3030
var sus = 0, cmin = File.read_uint16(3), cmlen = File.read_uint16(5), cmsz = File.read_uint8(7),
3131
x0 = File.read_uint16(8), y0 = File.read_uint16(0xA),
3232
w = File.read_uint16(0xC), h = File.read_uint16(0xE), attr = File.read_uint8(0x11);
33-
if(!w || !h || w > 4096 || h > 2048 || x0 > 1600 || y0 > 1200 || cmsz > 32) return false;
33+
if(!w || !h || w > 4096 || h > 2048 || x0 > 1600 || y0 > 1200 || cmsz > 32 || (attr&0xC0)) return false;
3434
// suspiciousness is probably the only way to filter out all the FPs, so let's measure that
3535
if(x0) sus++; if(y0) sus++; if(w < 4) sus++; if(h < 4) sus++; if(w > 1600) sus++; if(h > 1200) sus++;
36+
if(attr&0x10) sus++; // that's right-to-left
3637
if(!cmsz && cmlen) return false;
3738
if(cmt == 1 && (it == 2 || it == 10)) sus++; //shouldn't have colour maps with True-color
3839
if(cmsz < 15 || isWithin(cmsz,17,23) || isWithin(cmsz,25,31)) sus++; if(cmlen > 256) sus++; if(cmin) sus++;
39-
if(it == 0) { if(cmin) sus++; if(cmlen) sus++; if(cmsz) sus++ }
40+
if(it == 2 || it == 10) { if(cmin) sus++; if(cmlen) sus++; if(cmsz) sus++ }
4041
if(it != 1 && it != 9 && it != 32 && it != 33) depth = bpp <= 8 ? 8 : (bpp <= 16 ? 5 : 8);
4142
else depth = cmsz <= 8 ? 8 : (cmsz <= 16 ? 5 : 8);
4243
var col = 1 << depth;
@@ -141,9 +142,7 @@ function detect(bShowType,bShowVersion,bShowOptions) {
141142
if(co != "rle" || File.isDeepScan()) sOption(outSz(p),"sz:")
142143
}
143144
if(bad != "") sVersion += "/malformed"+bad;
144-
145145
bDetected = true;
146-
return result(bShowType,bShowVersion,bShowOptions);
147-
148-
return result();
146+
147+
return result();
149148
}

0 commit comments

Comments
 (0)