wav_reader: check read ds64 - check overflow

This commit is contained in:
Martin Pulec
2022-10-21 08:24:21 +02:00
parent a005e9169e
commit fa6ff516cd

View File

@@ -195,8 +195,9 @@ static _Bool read_ds64(FILE *wav_file, uint32_t chunk_size, struct wav_metadata
metadata->data_size = tmp;
READ_N(&tmp, 8); // dummy - should be ignored
uint32_t table_count = 0;
const int table_sz = (sizeof(uint32_t) /*ID*/ + sizeof(uint64_t) /*size*/);
const size_t table_sz = (sizeof(uint32_t) /*ID*/ + sizeof(uint64_t) /*size*/);
READ_N(&table_count, 4); // number of table entries for non-'data' chunks
assert(table_sz * table_count <= MIN(sizeof(uint32_t), sizeof(long))); // check overflows
if (chunk_size - 28 != table_sz * table_count) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "incorrect table count %" PRIu32 " given, ds64 chunk len %" PRIu32 "\n",
table_count, chunk_size);