mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Tighten magic_number_guess_fourcc TGA heuristic
Prior to this commit, test/data/cbor-rfc-7049-examples.cbor was incorrectly sniffed as TGA. /usr/bin/file did this too. $ file test/data/cbor-rfc-7049-examples.cbor test/data/cbor-rfc-7049-examples.cbor: Targa image data - Map 59395 x 26 x 15 +6169 +6500 - 2-bit alpha - interleave "@\033" Updates #67
This commit is contained in:
1 parent
ed4d556721
commit
c82793a984
2 files changed
+30
-22
No files matched your search
@@ -90,19 +90,23 @@ wuffs_base__magic_number_guess_fourcc__maybe_tga(
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow-list for the Color Map Entry Size field.
|
||||
// Allow-list for the Color Map Entry Size field (if the Color Map Type field
|
||||
// is non-zero) or else all the Color Map fields should be zero.
|
||||
if (prefix_data.len < 8) {
|
||||
return prefix_closed ? 0 : -1;
|
||||
}
|
||||
switch (prefix_data.ptr[7]) {
|
||||
case 0x00:
|
||||
case 0x0F:
|
||||
case 0x10:
|
||||
case 0x18:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
} else if (prefix_data.ptr[1] != 0x00) {
|
||||
switch (prefix_data.ptr[7]) {
|
||||
case 0x0F:
|
||||
case 0x10:
|
||||
case 0x18:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
} else if ((prefix_data.ptr[3] | prefix_data.ptr[4] | prefix_data.ptr[5] |
|
||||
prefix_data.ptr[6] | prefix_data.ptr[7]) != 0x00) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow-list for the Pixel Depth field.
|
||||
|
||||
@@ -16012,19 +16012,23 @@ wuffs_base__magic_number_guess_fourcc__maybe_tga(
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow-list for the Color Map Entry Size field.
|
||||
// Allow-list for the Color Map Entry Size field (if the Color Map Type field
|
||||
// is non-zero) or else all the Color Map fields should be zero.
|
||||
if (prefix_data.len < 8) {
|
||||
return prefix_closed ? 0 : -1;
|
||||
}
|
||||
switch (prefix_data.ptr[7]) {
|
||||
case 0x00:
|
||||
case 0x0F:
|
||||
case 0x10:
|
||||
case 0x18:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
} else if (prefix_data.ptr[1] != 0x00) {
|
||||
switch (prefix_data.ptr[7]) {
|
||||
case 0x0F:
|
||||
case 0x10:
|
||||
case 0x18:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
} else if ((prefix_data.ptr[3] | prefix_data.ptr[4] | prefix_data.ptr[5] |
|
||||
prefix_data.ptr[6] | prefix_data.ptr[7]) != 0x00) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow-list for the Pixel Depth field.
|
||||
|
||||
Reference in new issue
Block a user