fix buncha ignored errors and whatever

This commit is contained in:
Alcaro 2017-10-06 01:53:00 +02:00
parent 1e3da091a5
commit 76283edd07
3 changed files with 25 additions and 16 deletions

View File

@ -119,20 +119,20 @@ static INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
register unsigned crc = br->read_crc16;
#if FLAC__BYTES_PER_WORD == 4
switch(br->crc16_align) {
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 24), crc);
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 24), crc); // fallthrough
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc); // fallthrough
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc); // fallthrough
case 24: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
}
#elif FLAC__BYTES_PER_WORD == 8
switch(br->crc16_align) {
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 56), crc);
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 48) & 0xff), crc);
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 40) & 0xff), crc);
case 24: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 32) & 0xff), crc);
case 32: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 24) & 0xff), crc);
case 40: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
case 48: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 56), crc); // fallthrough
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 48) & 0xff), crc); // fallthrough
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 40) & 0xff), crc); // fallthrough
case 24: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 32) & 0xff), crc); // fallthrough
case 32: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 24) & 0xff), crc); // fallthrough
case 40: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc); // fallthrough
case 48: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc); // fallthrough
case 56: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
}
#else

View File

@ -621,6 +621,8 @@ chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t comple
/* reset and decode */
lzma_codec_decompress(&cdlz->base_decompressor, &src[header_bytes], complen_base, &cdlz->buffer[0], frames * CD_MAX_SECTOR_DATA);
#ifdef WANT_SUBCODE
if (header_bytes + complen_base >= complen)
return CHDERR_DECOMPRESSION_ERROR;
zlib_codec_decompress(&cdlz->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdlz->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
#endif
@ -2073,7 +2075,8 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
case V34_MAP_ENTRY_TYPE_COMPRESSED:
/* read it into the decompression buffer */
core_fseek(chd->file, entry->offset, SEEK_SET);
if (core_fseek(chd->file, entry->offset, SEEK_SET) != 0)
return CHDERR_READ_ERROR;
bytes = core_fread(chd->file, chd->compressed, entry->length);
if (bytes != entry->length)
return CHDERR_READ_ERROR;
@ -2089,7 +2092,8 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
/* uncompressed data */
case V34_MAP_ENTRY_TYPE_UNCOMPRESSED:
core_fseek(chd->file, entry->offset, SEEK_SET);
if (core_fseek(chd->file, entry->offset, SEEK_SET) != 0)
return CHDERR_READ_ERROR;
bytes = core_fread(chd->file, dest, chd->header.hunkbytes);
if (bytes != chd->header.hunkbytes)
return CHDERR_READ_ERROR;
@ -2158,8 +2162,10 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
case COMPRESSION_TYPE_1:
case COMPRESSION_TYPE_2:
case COMPRESSION_TYPE_3:
core_fseek(chd->file, blockoffs, SEEK_SET);
core_fread(chd->file, chd->compressed, blocklen);
if (core_fseek(chd->file, blockoffs, SEEK_SET) != 0);
return CHDERR_READ_ERROR;
if (core_fread(chd->file, chd->compressed, blocklen) != blocklen)
return CHDERR_READ_ERROR;
switch (chd->codecintf[rawmap[0]]->compression)
{
case CHD_CODEC_CD_LZMA:
@ -2186,8 +2192,10 @@ static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *des
return CHDERR_NONE;
case COMPRESSION_NONE:
core_fseek(chd->file, blockoffs, SEEK_SET);
core_fread(chd->file, dest, chd->header.hunkbytes);
if (core_fseek(chd->file, blockoffs, SEEK_SET) != 0)
return CHDERR_READ_ERROR;
if (core_fread(chd->file, dest, chd->header.hunkbytes) != chd->header.hunkbytes)
return CHDERR_READ_ERROR;
#ifdef VERIFY_BLOCK_CRC
if (crc16(dest, chd->header.hunkbytes) != blockcrc)
return CHDERR_DECOMPRESSION_ERROR;

View File

@ -304,6 +304,7 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
/* build the lookup table */
huffman_build_lookup_table(decoder);
delete_huffman_decoder(smallhuff);
/* determine final input length and report errors */
return bitstream_overflow(bitbuf) ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;