mirror of
https://github.com/panzi/mediaextract
synced 2025-02-20 23:07:07 +00:00
S3M: less false positives
This commit is contained in:
parent
135128c628
commit
0476cd4776
@ -17,10 +17,10 @@
|
||||
(magic[0] == 'T' && \
|
||||
magic[1] == 'D' && \
|
||||
magic[2] == 'Z' && \
|
||||
magic[3] >= '0' && magic[3] <= '9')
|
||||
magic[3] > '0' && magic[3] <= '9')
|
||||
|
||||
#define IS_MOD_XCHN_MAGIC(magic) \
|
||||
(magic[0] >= '0' && magic[0] <= '9' && \
|
||||
(magic[0] > '0' && magic[0] <= '9' && \
|
||||
magic[1] == 'C' && \
|
||||
magic[2] == 'H' && \
|
||||
magic[3] == 'N')
|
||||
|
17
src/s3m.c
17
src/s3m.c
@ -8,18 +8,23 @@ int s3m_isfile(const uint8_t *data, size_t input_len, size_t *lengthptr)
|
||||
uint8_t mark = data[28];
|
||||
uint8_t type = data[29];
|
||||
|
||||
if (mark != 0x1A || type != 16)
|
||||
if (mark != 0x1A || type != 0x10)
|
||||
return 0;
|
||||
|
||||
if (MAGIC(data + S3M_MAGIC_OFFSET) != S3M_MAGIC)
|
||||
return 0;
|
||||
|
||||
uint16_t orders = le16toh(*(uint16_t *)(data + 32));
|
||||
uint16_t samples = le16toh(*(uint16_t *)(data + 34));
|
||||
uint16_t patterns = le16toh(*(uint16_t *)(data + 36));
|
||||
size_t length = S3M_HEADER_SIZE + orders + (samples << 1) + (patterns << 1);
|
||||
uint16_t orders = le16toh(*(uint16_t *)(data + 32));
|
||||
uint16_t samples = le16toh(*(uint16_t *)(data + 34));
|
||||
uint16_t patterns = le16toh(*(uint16_t *)(data + 36));
|
||||
uint16_t tracker_vers = le16toh(*(uint16_t *)(data + 40));
|
||||
uint16_t format_vers = le16toh(*(uint16_t *)(data + 42));
|
||||
size_t length = S3M_HEADER_SIZE + orders +
|
||||
((size_t)samples << 1) + ((size_t)patterns << 1);
|
||||
|
||||
if (input_len < length)
|
||||
if (input_len < length ||
|
||||
tracker_vers < 0x1000 || tracker_vers >= 0x6000 ||
|
||||
format_vers < 1 || format_vers > 2)
|
||||
return 0;
|
||||
|
||||
#define UPDATE_LENGTH(len) \
|
||||
|
Loading…
Reference in New Issue
Block a user